You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because of how Claude Code handles prompt injection of the instructions within slash commands, they offer finer grain control over how the agent operates.
task-context-enhanced.md is one part of a multi-phase workflow provided here as reference.
next.md is used by CC to determine the current phase and move to the next one, enabling it to easily run through every phase of the workflow without stopping or pausing.
Automatically advances to the next appropriate command based on current workflow state.
State Detection:
Find Current Persona
Search for most recent: ## [PERSONA: PM|DEV|QA]
Find Last Command
Search for most recent: /task:* or /workflow:*
Determine Next Step
Workflow Progression Map:
PM Persona Flow:
After /task:start → Run /task:context
After /task:context → Run /task:plan
After /task:plan → Switch to QA → Run /task:test
After /task:complete → Run /task:start (new task)
QA Persona Flow:
After /task:test → Switch to DEV → Run /task:implement
After /task:validate:
If PASSED → Switch to PM → Run /task:complete
If FAILED → Switch to DEV → Run /task:implement
DEV Persona Flow:
After /task:implement → Switch to QA → Run /task:validate
Decision Logic:
Current State → Next Action:
NO TASK LOADED:
→ Run /task:start <next-pending-task>
TASK LOADED, NO CONTEXT:
→ Run /task:context
CONTEXT COMPLETE, NO PLAN:
→ Run /task:plan
PLAN COMPLETE, NO TESTS:
→ Switch to QA
→ Run /task:test
TESTS CREATED, NOT IMPLEMENTED:
→ Switch to DEV
→ Run /task:implement
IMPLEMENTATION COMPLETE, NOT VALIDATED:
→ Switch to QA
→ Run /task:validate
VALIDATION COMPLETE:
→ Switch to PM
→ Run /task:complete
TASK COMPLETED:
→ Check for next PENDING task
→ Run /task:start <next-task>
AMBIGUOUS STATE:
→ Run /workflow:help
Persona Handoffs:
When switching personas, use this format:
Current: [PERSONA: PM]
Switching to QA for test design...
## [PERSONA: QA] - {{Task}} - Test Design
Now running: /task:test
Edge Cases:
No pending tasks:
All tasks completed! 🎉
Run /workflow:help to see project status
Multiple IN_PROGRESS tasks:
Multiple tasks in progress. Please specify:
- TASK-001: {{description}}
- TASK-002: {{description}}
Run /task:start <task-id>
Unclear state:
Cannot determine current state.
Run /workflow:help to see options
Output Examples:
Clear progression:
Detected: [PERSONA: PM] last ran /task:context
Next: Run /task:plan
Persona switch:
Detected: [PERSONA: PM] completed planning
Switching to QA persona...
Next: Run /task:test
Task completion:
Detected: [PERSONA: PM] validation passed
Next: Run /task:complete
🚫 REFUSAL TRIGGERS:
Corrupted state → "REFUSAL: Cannot parse workflow state"
No conversation history → "REFUSAL: No context available"
Next: Automatically determined based on state
Continue workflow with the appropriate next command.
❌ ABORT if: No task in current session → Run /task:start first
✅ PROCEED if: Task clearly loaded in conversation
Phase 1: Local Context Searches
Execute ALL of these searches and document results:
# 1. Search for existing specs
ls -la .claude/specs/*{{feature}}*.md
grep -r "{{feature}}" .claude/specs/*.md
# 2. Search project documentation
grep -r "{{feature}}"*.md docs/*.md
# 3. Search existing code
grep -r "{{feature}}" --include="*.py".
find . -name "*{{feature}}*" -type f
# 4. Check for related types/enums
grep -r "class.*{{Feature}}" --include="*.py".
grep -r "{{FEATURE}}" --include="*.py".# Check for enums
Phase 2: External Documentation (Context7)
If available, search for relevant library documentation:
# Check if feature involves external librariesifuses_external_libraries:
try:
# Example: For fastapi featurescontext7.resolve_library_id("fastapi")
context7.get_library_docs("/fastapi/fastapi", topic="{{feature}}")
# Example: For pytest featurescontext7.resolve_library_id("pytest")
context7.get_library_docs("/pytest-dev/pytest", topic="{{feature}}")
# Example: For specific technologycontext7.resolve_library_id("{{library_name}}")
context7.get_library_docs("{{library_id}}", topic="{{feature}}")
exceptToolNotAvailable:
# Note: Context7 not available, proceeding with local search onlypass
Phase 3: AI-Powered Pattern Search (if needed)
For complex features spanning multiple files:
<Task>
prompt: |
Search the codebase for all references to {{feature}} including:
- Import statements
- Class definitions
- Function signatures
- Configuration references
- Test implementations
Focus on understanding the integration patterns and dependencies.
description: Deep search for {{feature}} patterns
</Task>
Documentation Template:
CONTEXT SEARCH RESULTS for {{task_id}}:
📁 SPECS FOUND:
- [List specific files or "NONE FOUND"]
📚 DOCUMENTATION:
- [List relevant sections or "NONE FOUND"]
💻 CODE REFERENCES:
- [List files and line numbers or "NONE FOUND"]
🔍 RELATED TYPES/ENUMS:
- [List discoveries or "NONE FOUND"]
📖 EXTERNAL DOCS (Context7):
- [Library]: [Relevant patterns/examples found]
- [Or "Context7 not available" / "No relevant external docs"]
🧩 INTEGRATION PATTERNS:
- [Patterns discovered via deep search]
- [Common usage examples in codebase]
📋 SPEC DECISION:
[If no spec exists]
- Feature size: {{Small|Medium|Large}}
- Template selected: {{LEAN|STANDARD|ITERATIVE}}
- Creating: .claude/specs/{{task_id}}-{{feature}}.md
Context7 Best Practices:
Library Resolution First
# Always resolve library ID before fetching docsresult=context7.resolve_library_id("library_name")
# Use the exact ID from result
Focused Topic Queries
# Good: Specific feature/APIget_library_docs("/org/lib", topic="middleware")
# Bad: Too broadget_library_docs("/org/lib", topic="everything")
Common Libraries to Check
Web frameworks: fastapi, django, flask
Testing: pytest, unittest
Data: pandas, numpy, pydantic
AI/ML: anthropic, openai, transformers
Infrastructure: redis, postgresql, docker
🚫 REFUSAL TRIGGERS:
No task loaded → "REFUSAL: No task loaded. Run /task:start first"
Skipped searches → "REFUSAL: All context searches must be executed"
Context7 errors → Note but don't block progress
Graceful Degradation:
If Context7 is unavailable:
Note in output: "External documentation search unavailable"
Rely on local searches and project knowledge
Consider using web search for critical documentation
Continue with workflow - don't block on external tools