mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
refactor(enhance-prompt): update description and streamline enhancement pipeline by removing codebase analysis references
This commit is contained in:
@@ -1,37 +1,22 @@
|
||||
---
|
||||
name: enhance-prompt
|
||||
description: Enhanced prompt transformation using session memory and codebase analysis with --enhance flag detection
|
||||
description: Enhanced prompt transformation using session memory and intent analysis with --enhance flag detection
|
||||
argument-hint: "user input to enhance"
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Systematically enhances user prompts by combining session memory context with codebase patterns, translating ambiguous requests into actionable specifications.
|
||||
Systematically enhances user prompts by leveraging session memory context and intent analysis, translating ambiguous requests into actionable specifications.
|
||||
|
||||
## Core Protocol
|
||||
|
||||
**Enhancement Pipeline:**
|
||||
`Intent Translation` → `Context Integration` → `Gemini Analysis (if needed)` → `Structured Output`
|
||||
`Intent Translation` → `Context Integration` → `Structured Output`
|
||||
|
||||
**Context Sources:**
|
||||
- Session memory (conversation history, previous analysis)
|
||||
- Codebase patterns (via Gemini when triggered)
|
||||
- Implicit technical requirements
|
||||
|
||||
## Gemini Trigger Logic
|
||||
|
||||
```pseudo
|
||||
FUNCTION should_use_gemini(user_prompt):
|
||||
critical_keywords = ["refactor", "migrate", "redesign", "auth", "payment", "security"]
|
||||
|
||||
RETURN (
|
||||
prompt_affects_multiple_modules(user_prompt, threshold=3) OR
|
||||
any_keyword_in_prompt(critical_keywords, user_prompt)
|
||||
)
|
||||
END
|
||||
```
|
||||
|
||||
**Gemini Integration:** ~/.claude/workflows/intelligent-tools-strategy.md
|
||||
- User intent patterns
|
||||
|
||||
## Enhancement Rules
|
||||
|
||||
@@ -47,22 +32,18 @@ END
|
||||
|
||||
### Context Integration Strategy
|
||||
|
||||
**Session Memory First:**
|
||||
**Session Memory:**
|
||||
- Reference recent conversation context
|
||||
- Reuse previously identified patterns
|
||||
- Build on established understanding
|
||||
|
||||
**Codebase Analysis (via Gemini):**
|
||||
- Only when complexity requires it
|
||||
- Focus on integration points
|
||||
- Identify existing patterns
|
||||
- Infer technical requirements from discussion
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
# User: "add login"
|
||||
# Session Memory: Previous auth discussion, JWT mentioned
|
||||
# Inferred: JWT-based auth, integrate with existing session management
|
||||
# Gemini (if multi-module): Analyze AuthService patterns, middleware structure
|
||||
# Action: Implement JWT authentication with session persistence
|
||||
```
|
||||
|
||||
## Output Structure
|
||||
@@ -76,7 +57,7 @@ ATTENTION: [Critical constraints]
|
||||
|
||||
### Output Examples
|
||||
|
||||
**Simple (no Gemini):**
|
||||
**Example 1:**
|
||||
```bash
|
||||
# Input: "fix login button"
|
||||
INTENT: Debug non-functional login button
|
||||
@@ -85,28 +66,28 @@ ACTION: Check event binding → verify state updates → test auth flow
|
||||
ATTENTION: Preserve existing OAuth integration
|
||||
```
|
||||
|
||||
**Complex (with Gemini):**
|
||||
**Example 2:**
|
||||
```bash
|
||||
# Input: "refactor payment code"
|
||||
INTENT: Restructure payment module for maintainability
|
||||
CONTEXT: Session memory - PCI compliance requirements
|
||||
Gemini - PaymentService → StripeAdapter pattern identified
|
||||
ACTION: Extract reusable validators → isolate payment gateway logic
|
||||
CONTEXT: Session memory - PCI compliance requirements, Stripe integration patterns
|
||||
ACTION: Extract reusable validators → isolate payment gateway logic → maintain adapter pattern
|
||||
ATTENTION: Zero behavior change, maintain PCI compliance, full test coverage
|
||||
```
|
||||
|
||||
## Automatic Triggers
|
||||
## Enhancement Triggers
|
||||
|
||||
- Ambiguous language: "fix", "improve", "clean up"
|
||||
- Multi-module impact (>3 modules)
|
||||
- Vague requests requiring clarification
|
||||
- Complex technical requirements
|
||||
- Architecture changes
|
||||
- Critical systems: auth, payment, security
|
||||
- Complex refactoring
|
||||
- Multi-step refactoring
|
||||
|
||||
## Key Principles
|
||||
|
||||
1. **Memory First**: Leverage session context before analysis
|
||||
2. **Minimal Gemini**: Only when complexity demands it
|
||||
3. **Context Reuse**: Build on previous understanding
|
||||
4. **Clear Output**: Structured, actionable specifications
|
||||
1. **Session Memory First**: Leverage conversation context and established understanding
|
||||
2. **Context Reuse**: Build on previous discussions and decisions
|
||||
3. **Clear Output**: Structured, actionable specifications
|
||||
4. **Intent Clarification**: Transform vague requests into specific technical goals
|
||||
5. **Avoid Duplication**: Reference existing context, don't repeat
|
||||
@@ -236,35 +236,31 @@ SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]
|
||||
- `.workflow/[sessionId]/.task/IMPL-*.json` exists (at least one)
|
||||
- `.workflow/[sessionId]/TODO_LIST.md` exists
|
||||
|
||||
<!-- TodoWrite: When task-generate-agent invoked, INSERT 3 task-generate-agent tasks -->
|
||||
<!-- TodoWrite: When task-generate-agent invoked, ATTACH 1 agent task -->
|
||||
|
||||
**TodoWrite Update (Phase 4 SlashCommand invoked - tasks attached)**:
|
||||
**TodoWrite Update (Phase 4 SlashCommand invoked - agent task attached)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Phase 4.1: Discovery - analyze requirements (task-generate-agent)", "status": "in_progress", "activeForm": "Analyzing requirements"},
|
||||
{"content": "Phase 4.2: Planning - design tasks (task-generate-agent)", "status": "pending", "activeForm": "Designing tasks"},
|
||||
{"content": "Phase 4.3: Output - generate JSONs (task-generate-agent)", "status": "pending", "activeForm": "Generating task JSONs"}
|
||||
{"content": "Execute task-generate-agent", "status": "in_progress", "activeForm": "Executing task-generate-agent"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: SlashCommand invocation **attaches** task-generate-agent's 3 tasks. Orchestrator **executes** these tasks.
|
||||
**Note**: Single agent task attached. Agent autonomously completes discovery, planning, and output generation internally.
|
||||
|
||||
**Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
|
||||
<!-- TodoWrite: After agent completes, mark task as completed -->
|
||||
|
||||
<!-- TodoWrite: After Phase 4 tasks complete, REMOVE Phase 4.1-4.3, restore to orchestrator view -->
|
||||
|
||||
**TodoWrite Update (Phase 4 completed - tasks collapsed)**:
|
||||
**TodoWrite Update (Phase 4 completed)**:
|
||||
```json
|
||||
[
|
||||
{"content": "Execute session discovery", "status": "completed", "activeForm": "Executing session discovery"},
|
||||
{"content": "Execute context gathering", "status": "completed", "activeForm": "Executing context gathering"},
|
||||
{"content": "Execute task generation", "status": "completed", "activeForm": "Executing task generation"}
|
||||
{"content": "Execute task-generate-agent", "status": "completed", "activeForm": "Executing task-generate-agent"}
|
||||
]
|
||||
```
|
||||
|
||||
**Note**: Phase 4 tasks completed and collapsed to summary.
|
||||
**Note**: Agent task completed. No collapse needed (single task).
|
||||
|
||||
**Return to User**:
|
||||
```
|
||||
@@ -288,31 +284,35 @@ Quality Gate: Consider running /workflow:action-plan-verify to catch issues earl
|
||||
|
||||
1. **Task Attachment** (when SlashCommand invoked):
|
||||
- Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
|
||||
- Example: `/workflow:tools:context-gather` attaches 3 sub-tasks (Phase 2.1, 2.2, 2.3)
|
||||
- **Phase 2, 3**: Multiple sub-tasks attached (e.g., Phase 2.1, 2.2, 2.3)
|
||||
- **Phase 4**: Single agent task attached (e.g., "Execute task-generate-agent")
|
||||
- First attached task marked as `in_progress`, others as `pending`
|
||||
- Orchestrator **executes** these attached tasks sequentially
|
||||
|
||||
2. **Task Collapse** (after sub-tasks complete):
|
||||
- Remove detailed sub-tasks from TodoWrite
|
||||
- **Applies to Phase 2, 3**: Remove detailed sub-tasks from TodoWrite
|
||||
- **Collapse** to high-level phase summary
|
||||
- Example: Phase 2.1-2.3 collapse to "Execute context gathering: completed"
|
||||
- **Phase 4**: No collapse needed (single task, just mark completed)
|
||||
- Maintains clean orchestrator-level view
|
||||
|
||||
3. **Continuous Execution**:
|
||||
- After collapse, automatically proceed to next pending phase
|
||||
- After completion, automatically proceed to next pending phase
|
||||
- No user intervention required between phases
|
||||
- TodoWrite dynamically reflects current execution state
|
||||
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase invoked (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins → Repeat until all phases complete.
|
||||
**Lifecycle Summary**: Initial pending tasks → Phase invoked (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary for Phase 2/3, or marked completed for Phase 4) → Next phase begins → Repeat until all phases complete.
|
||||
|
||||
### Benefits
|
||||
|
||||
- ✓ Real-time visibility into sub-task execution
|
||||
- ✓ Clear mental model: SlashCommand = attach → execute → collapse
|
||||
- ✓ Clear mental model: SlashCommand = attach → execute → collapse (Phase 2/3) or complete (Phase 4)
|
||||
- ✓ Clean summary after completion
|
||||
- ✓ Easy to track workflow progress
|
||||
|
||||
**Note**: See individual Phase descriptions (Phase 2, 3, 4) for detailed TodoWrite Update examples with full JSON structures.
|
||||
**Note**: See individual Phase descriptions for detailed TodoWrite Update examples:
|
||||
- **Phase 2, 3**: Multiple sub-tasks with attach/collapse pattern
|
||||
- **Phase 4**: Single agent task (no collapse needed)
|
||||
|
||||
## Input Processing
|
||||
|
||||
@@ -425,20 +425,21 @@ Conditional Branch: Check conflict_risk
|
||||
└─ ELSE: Skip Phase 3, proceed to Phase 4
|
||||
↓
|
||||
Phase 4: Task Generation (SlashCommand invoked)
|
||||
→ ATTACH 3 tasks: ← ATTACHED
|
||||
- Phase 4.1: Discovery - analyze requirements
|
||||
- Phase 4.2: Planning - design tasks
|
||||
- Phase 4.3: Output - generate JSONs
|
||||
→ Execute Phase 4.1-4.3
|
||||
→ COLLAPSE tasks ← COLLAPSED
|
||||
→ ATTACH 1 agent task: ← ATTACHED
|
||||
- Execute task-generate-agent
|
||||
→ Agent autonomously completes internally:
|
||||
(discovery → planning → output)
|
||||
→ Outputs: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
|
||||
↓
|
||||
Return summary to user
|
||||
```
|
||||
|
||||
**Key Points**:
|
||||
- **← ATTACHED**: Sub-tasks attached to TodoWrite when SlashCommand invoked
|
||||
- **← COLLAPSED**: Sub-tasks collapsed to summary after completion
|
||||
- **← ATTACHED**: Tasks attached to TodoWrite when SlashCommand invoked
|
||||
- Phase 2, 3: Multiple sub-tasks
|
||||
- Phase 4: Single agent task
|
||||
- **← COLLAPSED**: Sub-tasks collapsed to summary after completion (Phase 2, 3 only)
|
||||
- **Phase 4**: Single agent task, no collapse (just mark completed)
|
||||
- **Conditional Branch**: Phase 3 only executes if conflict_risk ≥ medium
|
||||
- **Continuous Flow**: No user intervention between phases
|
||||
|
||||
|
||||
Reference in New Issue
Block a user