feat: optimize prompt-enhancer skill with bilingual support

- Add Chinese semantic recognition (修复/优化/重构/更新/改进/清理)
- Support -e/--enhance flags for explicit triggering
- Streamline structure with tables and concise format
- Add bilingual confirmation workflow (EN/CN)
- Reduce examples section for better readability
- Implement 4-priority trigger system (P1-P4)
- Add visual workflow pipeline diagram

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-10-18 22:03:09 +08:00
parent 1073e43c0b
commit 1324fb8c2a

View File

@@ -1,100 +1,132 @@
---
name: Prompt Enhancer
description: Systematically enhance unclear and ambiguous user prompts by combining session memory with codebase analysis. AUTO-TRIGGER when user input is vague, lacks technical specificity (e.g., "fix", "improve", "clean up", "update", "refactor"), uses unclear references ("it", "that", "this thing"), or affects multiple modules or critical systems. Essential for transforming vague intent into actionable specifications.
allowed-tools: Bash, Read, Glob, Grep
description: Transform vague prompts into actionable specs using session memory + semantic analysis. AUTO-TRIGGER on (1) -e/--enhance flags, (2) vague keywords (fix/improve/refactor/修复/优化/重构), (3) unclear refs (it/that/这个/那个), (4) multi-module scope. Supports English + Chinese semantic recognition.
allowed-tools: Bash, Read, Glob, Grep, AskUserQuestion
---
# Prompt Enhancer
## Overview
**Transform**: Vague intent → Structured specification
Transforms ambiguous user requests into actionable technical specifications through semantic analysis and session memory integration.
**Languages**: English + Chinese (中英文语义识别)
**Core Capability**: Vague intent → Structured specification
## Triggers
## Enhancement Process
| Priority | Condition | Examples | Action |
|----------|-----------|----------|--------|
| **P1** | `-e` / `--enhance` flag | "fix auth -e", "优化性能 --enhance" | Immediate enhancement |
| **P2** | Vague keywords | EN: fix/improve/refactor<br>CN: 修复/优化/重构/更新/改进 | Semantic analysis |
| **P3** | Unclear references | EN: it/that/the code<br>CN: 这个/那个/它/代码 | Context extraction |
| **P4** | Multi-module scope | >3 modules or critical systems | Dependency analysis |
### Step 1: Semantic Analysis
## Process (4 Steps)
Analyze user input to identify:
- **Intent keywords**: fix, improve, add, refactor, update, migrate
- **Technical scope**: single file vs multi-module
- **Domain context**: auth, payment, security, API, UI, database
- **Implied requirements**: performance, security, testing, documentation
### 1. Semantic Analysis
Identify: Intent keywords (EN/CN) → Scope (file/module/system) → Domain (auth/API/DB/UI)
### Step 2: Memory Analysis
**English**: fix, improve, add, refactor, update, migrate
**Chinese**: 修复, 优化, 添加, 重构, 更新, 迁移, 改进, 清理
Extract from conversation history:
- **Technical context**: Previous discussions, decisions, implementations
- **Known patterns**: Identified code patterns, architecture decisions
- **Current state**: What's been built, what's in progress
- **Dependencies**: Related modules, integration points
- **Constraints**: Security requirements, backward compatibility
### 2. Memory Extraction
Extract: Technical context → Current state → Dependencies → Constraints
### Step 3: Context Integration
### 3. Integration
Combine: Precise intent + Action steps (with files) + Critical constraints
Combine semantic and memory analysis to determine:
- **Precise intent**: Specific technical goal
- **Required actions**: Implementation steps with file references
- **Critical constraints**: Security, compatibility, testing requirements
- **Missing information**: What needs clarification
### 4. User Confirmation (REQUIRED)
Use AskUserQuestion with 3 options → Execute/Review/Refine
## Output Structure
Every enhanced prompt must follow this format:
## Output Format
```
INTENT: [Clear technical goal]
CONTEXT: [Session memory + semantic analysis]
ACTION: [Numbered implementation steps]
ATTENTION: [Critical constraints]
INTENT: [One-sentence technical goal]
CONTEXT: [Session memory + domain analysis]
ACTION:
1. [Step with file references]
2. [Step with file references]
3. [...]
ATTENTION: [Security/compatibility/testing constraints]
```
**Field Descriptions**:
## Semantic Patterns (EN + CN)
- **INTENT**: One-sentence technical goal derived from semantic analysis
- **CONTEXT**: Session memory findings + semantic domain analysis
- **ACTION**: Numbered steps with specific file/module references
- **ATTENTION**: Critical constraints, security, compliance, tests
## Semantic Patterns
### Intent Translation
| User Input | Semantic Intent | Focus |
|------------|----------------|-------|
| "fix" + vague target | Debug and resolve | Root cause → preserve behavior |
| "improve" + no metrics | Enhance/optimize | Performance/readability |
| "add" + feature name | Implement feature | Integration + edge cases |
| "refactor" + module | Restructure | Maintain behavior |
| "update" + version | Modernize | Version compatibility |
| Intent (EN/CN) | Semantic Meaning | Focus |
|----------------|------------------|-------|
| fix/修复 + vague target | Debug & resolve | Root cause → preserve behavior |
| improve/优化 + no metrics | Enhance/optimize | Performance/readability |
| add/添加 + feature | Implement feature | Integration + edge cases |
| refactor/重构 + module | Restructure | Maintain behavior |
| update/更新 + version | Modernize | Version compatibility |
| clean up/清理 + area | Simplify/organize | Remove redundancy |
### Scope Detection
**Single-file scope**:
- "fix button", "add validation", "update component"
- Use session memory only
| Input Pattern | Scope | Action |
|---------------|-------|--------|
| "fix button", "修复按钮" | Single file | Session memory only |
| "add auth", "添加认证" | Multi-module (>3) | Dependency analysis |
| "improve perf", "优化性能" | System-wide | Cross-cutting concerns |
**Multi-module scope** (>3 modules):
- "add authentication", "refactor payment", "migrate database"
- Analyze dependencies and integration points
## Workflow
**System-wide scope**:
- "improve performance", "add logging", "update security"
- Consider cross-cutting concerns
```
Trigger → Analyze → Enhance → Confirm → Execute
↓ ↓ ↓ ↓ ↓
P1-4 EN/CN INTENT/ 3 opts Direct
detect ACTION or iterate
```
## Key Principles
1. **Detect**: Check triggers (P1-P4)
2. **Analyze**: Semantic (EN/CN) + Memory extraction
3. **Enhance**: Generate structured output
4. **Confirm**: AskUserQuestion (Execute/Review/Refine)
5. **Execute**: Proceed based on user choice
1. **Memory First**: Check session memory before assumptions
2. **Semantic Precision**: Extract exact technical intent from vague language
3. **Context Reuse**: Build on previous understanding
4. **Clear Output**: Always structured format
5. **Avoid Duplication**: Reference context, don't repeat
## Confirmation (AskUserQuestion)
**Question**: "已增强提示词,如何继续?/ Enhanced prompt ready. Proceed?"
**Options**:
1. **Execute now** / **立即执行** - Proceed immediately
2. **Review first** / **先查看** - Show full spec before execution
3. **Refine** / **优化需求** - Iterate with user input
```typescript
AskUserQuestion({
questions: [{
question: "I've enhanced your prompt. How would you like to proceed? (已增强提示词,如何继续?)",
header: "Execution",
multiSelect: false,
options: [
{ label: "Execute now", description: "Proceed immediately with enhanced spec" },
{ label: "Review first", description: "Show full specification before execution" },
{ label: "Refine", description: "Let me adjust the requirements" }
]
}]
})
```
## Best Practices
- **Semantic analysis**: Identify domain, scope, and intent keywords
- **Memory integration**: Extract all relevant context from conversation
- **Structured output**: Always use INTENT/CONTEXT/ACTION/ATTENTION format
- **Actionable steps**: Specific files, clear execution order
- **Critical constraints**: Security, compatibility, testing requirements
- ✅ Detect `-e`/`--enhance` flags first (P1)
- ✅ Support EN + CN semantic keywords
- ✅ Extract session memory context
- ✅ Use INTENT/CONTEXT/ACTION/ATTENTION format
- ✅ ALWAYS confirm with AskUserQuestion
- ✅ Execute directly if "Execute now" selected
- ✅ Include file references in ACTION steps
## Examples
**Input**: "fix auth -e" / "优化性能 --enhance"
**Output**:
```
INTENT: [Clear technical goal / 明确技术目标]
CONTEXT: [Session memory findings / 会话记忆发现]
ACTION:
1. [Step with files / 带文件引用的步骤]
2. [Step with files / 带文件引用的步骤]
ATTENTION: [Constraints / 约束条件]
```
**Confirm** → Execute/Review/Refine