Skip to content

/execute-task - Intelligent Task Execution with Context Discovery

Purpose

The /execute-task prompt executes development tasks by first discovering what the task actually is, understanding the project context, and adapting implementation to match existing patterns. It thinks like an intelligent developer who explores before coding.

How It Actually Works

  1. Task Discovery:

    • Searches CLAUDE.md files for task descriptions
    • Looks in .orchestre/ for plans and task lists
    • Checks feature directories for local documentation
    • If task not found, helps discover available tasks
  2. Context Understanding:

    • Identifies project type from file structure
    • Discovers technologies from package files
    • Finds existing patterns and conventions
    • Studies coding style from existing code
  3. Adaptive Exploration (based on task type):

    • UI tasks → Components, views, pages
    • API tasks → Routes, controllers, handlers
    • Data tasks → Models, schemas, migrations
    • Config tasks → Config files, environment examples
  4. Implementation:

    • Follows discovered patterns
    • Uses project's coding style
    • Includes error handling
    • Adds tests if pattern exists
  5. Documentation:

    • Creates/updates CLAUDE.md in affected folders
    • Documents architectural decisions
    • Records patterns and gotchas
    • Notes TODOs and improvements

Use Cases

  1. Planned Tasks: Execute tasks from development plans
  2. Feature Implementation: Build new features with proper integration
  3. Bug Fixes: Diagnose and fix issues with understanding
  4. API Development: Create endpoints following existing patterns
  5. UI Components: Build interfaces matching your design system

Argument Structure

/execute-task <task-description>

Arguments

  1. task-description (required)
    • Task identifier from plans/documentation
    • Natural language task description
    • Reference to numbered tasks (e.g., "Step 1.2")

Examples

bash
# Execute planned task
/execute-task "Step 1.2: Implement authentication middleware"

# Feature implementation
/execute-task "Add user profile editing with avatar upload"

# Task from development plan
/execute-task "Phase 2 Task 3: Add real-time notifications"

# Bug fix
/execute-task "Fix authentication redirect loop"

# Referenced task
/execute-task "Build the data export feature from yesterday's plan"
/execute-task "Optimize database queries in the reporting module" --validate

Documentation Requirements

What Gets Documented

For New Features/Folders, creates CLAUDE.md with:

  • Module/feature purpose and overview
  • Key architectural decisions
  • Important files and their roles
  • Integration points
  • Patterns used and rationale
  • Gotchas and things to watch for
  • TODOs and future improvements

For Existing Code, updates nearest CLAUDE.md with:

  • What was added/changed (with date)
  • New patterns introduced
  • Dependencies added
  • Configuration changes
  • Discovered gotchas

Example Documentation

markdown
# Authentication Module

## Overview
JWT-based authentication with refresh tokens (implemented 2024-01-15)

## Key Files
- `middleware.ts` - Auth middleware for protected routes
- `tokens.ts` - JWT generation and validation
- `providers/` - OAuth provider integrations

## Architecture Decisions
- JWT with refresh tokens (access: 15min, refresh: 7 days)
- Redis for token blacklisting
- Rate limiting: 100 requests/hour per IP

## Integration Points
- All `/api/*` routes use auth middleware
- Frontend stores tokens in httpOnly cookies
- Refresh happens automatically on 401

## Gotchas
- Remember to blacklist tokens on logout
- OAuth redirect URLs must be whitelisted

Adaptation Strategies

Context Discovery

Before execution, the prompt:

  1. Analyzes Codebase

    • Finds relevant files and patterns
    • Understands existing architecture
    • Identifies integration points
    • Discovers conventions
  2. Reviews Memory

    • Checks project plans
    • Reads previous decisions
    • Understands constraints
    • Follows established patterns
  3. Identifies Dependencies

    • Maps component relationships
    • Finds API contracts
    • Understands data flow
    • Recognizes service boundaries

Intelligent Implementation

The prompt adapts by:

  • Matching existing code style
  • Using established patterns
  • Respecting architecture decisions
  • Maintaining consistency
  • Following team conventions

Progressive Enhancement

Starts simple and builds up:

  • Basic functionality first
  • Error handling next
  • Performance optimization
  • Security hardening
  • User experience polish

Memory Usage

Reads From

project/
├── CLAUDE.md                    # Project context
├── .orchestre/
│   ├── plans/                   # Implementation plans
│   ├── patterns/                # Discovered patterns
│   └── decisions/               # Technical decisions
└── src/
    └── **/CLAUDE.md            # Feature-specific context

Updates Memory

markdown
# Task Execution: User Profile Editing

## Implementation Details
- Location: /src/features/profile/
- Components: ProfileEditor, AvatarUpload
- API: PUT /api/users/:id/profile
- Storage: S3 for avatars

## Patterns Used
- Followed existing form validation pattern
- Used established image upload flow
- Integrated with current auth middleware
- Applied consistent error handling

## Decisions Made
- Chose S3 for avatar storage (scalability)
- Implemented optimistic UI updates
- Added image compression client-side
- Used existing notification system

## Testing
- Unit tests: ProfileEditor.test.tsx
- Integration: profile.integration.test.ts
- E2E: cypress/e2e/profile.cy.ts

Workflow Examples

Feature Implementation Flow

bash
# 1. Understand requirements
/execute-task "Review user stories for shopping cart feature"

# 2. Implement core functionality
/execute-task "Build shopping cart with add/remove items and persistence"

# 3. Add enhancements
/execute-task "Add cart animations and optimistic updates"

# 4. Integrate with existing systems
/execute-task "Connect cart to checkout flow and inventory system"

Bug Fix Workflow

bash
# 1. Investigate issue
/execute-task "Diagnose why users can't upload files larger than 5MB"

# 2. Implement fix
/execute-task "Fix file upload size limit and add proper error messages"

# 3. Prevent regression
/execute-task "Add tests for large file uploads"

Performance Optimization

bash
# 1. Profile current performance
/execute-task "Analyze dashboard loading performance"

# 2. Implement optimizations
/execute-task "Add pagination and lazy loading to dashboard widgets"

# 3. Validate improvements
/execute-task "Measure and document performance gains" --validate

Intelligent Features

Pattern Recognition

  • Identifies similar implementations
  • Reuses successful patterns
  • Avoids known anti-patterns
  • Suggests improvements

Code Generation

Generates code that:

  • Matches project style
  • Follows conventions
  • Includes proper types
  • Has error handling
  • Contains documentation

Integration Intelligence

  • Finds connection points
  • Maintains contracts
  • Updates related code
  • Preserves functionality
  • Tests integrations

Validation Steps

Automatically:

  • Runs existing tests
  • Checks for regressions
  • Validates requirements
  • Ensures code quality
  • Verifies integration

Task Categories

1. Feature Tasks

bash
/execute-task "Add two-factor authentication with SMS and authenticator app support"
  • Implements complete features
  • Integrates with existing systems
  • Adds appropriate tests
  • Updates documentation

2. Technical Tasks

bash
/execute-task "Migrate from REST to GraphQL for user service"
  • Handles complex migrations
  • Maintains backward compatibility
  • Updates all consumers
  • Provides migration path

3. Infrastructure Tasks

bash
/execute-task "Set up Redis caching for API responses"
  • Configures infrastructure
  • Integrates with application
  • Adds monitoring
  • Documents setup

4. Maintenance Tasks

bash
/execute-task "Update all dependencies and fix breaking changes"
  • Manages updates safely
  • Fixes compatibility issues
  • Runs comprehensive tests
  • Documents changes

Advanced Implementation

Multi-Step Execution

bash
# Complex task with phases
/execute-task "Implement multi-tenant data isolation with row-level security"

# Breaks down into:
# 1. Schema modifications
# 2. Security policy implementation
# 3. API updates
# 4. Testing and validation

Conditional Implementation

bash
# Adaptive based on findings
/execute-task "Optimize search functionality based on usage patterns"

# Discovers:
# - Current search implementation
# - Usage analytics
# - Performance bottlenecks
# Then implements appropriate solution

Cross-System Tasks

bash
# Coordinated changes
/execute-task "Implement event-driven inventory updates across services"

# Updates:
# - Inventory service
# - Order service  
# - Notification service
# - Event bus configuration

Integration Points

With Other Prompts

  • ← /orchestrate: Executes planned tasks
  • ← /discover-context: Uses discovered patterns
  • → /review: Validates implementation
  • → /document-feature: Documents what was built

With Development Flow

  • Integrates with Git workflow
  • Respects branch strategies
  • Creates appropriate commits
  • Supports pull requests

Best Practices

  1. Clear Task Definition

    bash
    # Good: Specific and measurable
    /execute-task "Add email verification with 24-hour expiry and resend capability"
    
    # Vague: Too broad
    /execute-task "Improve authentication"
  2. Reference Context

    bash
    # Good: Builds on existing work
    /execute-task "Implement the caching strategy we discussed in the performance review"
    
    # Isolated: No context
    /execute-task "Add caching"
  3. Incremental Progress

    bash
    # Step 1: Core functionality
    /execute-task "Build basic CRUD for products"
    
    # Step 2: Enhancements
    /execute-task "Add product search and filtering"
    
    # Step 3: Advanced features
    /execute-task "Implement product recommendations"

Error Handling

Common Scenarios

  1. Ambiguous Requirements

    • Prompt asks clarifying questions
    • Suggests interpretations
    • Provides options
    • Documents assumptions
  2. Technical Blockers

    • Identifies constraints
    • Suggests alternatives
    • Documents blockers
    • Proposes workarounds
  3. Integration Conflicts

    • Detects incompatibilities
    • Resolves conflicts
    • Updates dependencies
    • Maintains stability

Tips

  1. Start with Context: Let the prompt discover before doing
  2. Be Specific: Clear requirements lead to better implementation
  3. Think in Steps: Break large tasks into smaller ones
  4. Validate Early: Use --validate flag for critical changes
  5. Document Decisions: The prompt captures why, not just what

Built with ❤️ for the AI Coding community, by Praney Behl