Skip to content

Instantly share code, notes, and snippets.

@pillheadddd
Created June 20, 2025 14:41
Show Gist options
  • Save pillheadddd/9c8f5823856e6c857f85e613e31e1d90 to your computer and use it in GitHub Desktop.
Save pillheadddd/9c8f5823856e6c857f85e613e31e1d90 to your computer and use it in GitHub Desktop.
Claude Code Slash Command Reference

Custom Slash Command Example

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.

Next Command

/next

Smart Navigation

Automatically advances to the next appropriate command based on current workflow state.

State Detection:

  1. Find Current Persona
Search for most recent: ## [PERSONA: PM|DEV|QA]
  1. Find Last Command
Search for most recent: /task:* or /workflow:*
  1. 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:

  1. No pending tasks:

    All tasks completed! 🎉
    Run /workflow:help to see project status
    
  2. Multiple IN_PROGRESS tasks:

    Multiple tasks in progress. Please specify:
    - TASK-001: {{description}}
    - TASK-002: {{description}}
    Run /task:start <task-id>
    
  3. 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.

Task Context Command (Enhanced with Context7)

[PERSONA: PM] - Enhanced Context Search

Loading @.claude/process/Persona.md#PM guidelines

🛑 STOP! Pre-flight Verification

Verify task is loaded by checking conversation history:

✓ Task ID: {{current_task_id}}
✓ Task loaded via: /task:start

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 libraries
if uses_external_libraries:
    try:
        # Example: For fastapi features
        context7.resolve_library_id("fastapi")
        context7.get_library_docs("/fastapi/fastapi", topic="{{feature}}")

        # Example: For pytest features
        context7.resolve_library_id("pytest")
        context7.get_library_docs("/pytest-dev/pytest", topic="{{feature}}")

        # Example: For specific technology
        context7.resolve_library_id("{{library_name}}")
        context7.get_library_docs("{{library_id}}", topic="{{feature}}")
    except ToolNotAvailable:
        # Note: Context7 not available, proceeding with local search only
        pass

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:

  1. Library Resolution First

    # Always resolve library ID before fetching docs
    result = context7.resolve_library_id("library_name")
    # Use the exact ID from result
  2. Focused Topic Queries

    # Good: Specific feature/API
    get_library_docs("/org/lib", topic="middleware")
    
    # Bad: Too broad
    get_library_docs("/org/lib", topic="everything")
  3. 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:

  1. Note in output: "External documentation search unavailable"
  2. Rely on local searches and project knowledge
  3. Consider using web search for critical documentation
  4. Continue with workflow - don't block on external tools

Next: Run /next to continue workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment