/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
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
Context Understanding:
- Identifies project type from file structure
- Discovers technologies from package files
- Finds existing patterns and conventions
- Studies coding style from existing code
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
Implementation:
- Follows discovered patterns
- Uses project's coding style
- Includes error handling
- Adds tests if pattern exists
Documentation:
- Creates/updates CLAUDE.md in affected folders
- Documents architectural decisions
- Records patterns and gotchas
- Notes TODOs and improvements
Use Cases
- Planned Tasks: Execute tasks from development plans
- Feature Implementation: Build new features with proper integration
- Bug Fixes: Diagnose and fix issues with understanding
- API Development: Create endpoints following existing patterns
- UI Components: Build interfaces matching your design system
Argument Structure
/execute-task <task-description>Arguments
- task-description (required)
- Task identifier from plans/documentation
- Natural language task description
- Reference to numbered tasks (e.g., "Step 1.2")
Examples
# 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" --validateDocumentation 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
# 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 whitelistedAdaptation Strategies
Context Discovery
Before execution, the prompt:
Analyzes Codebase
- Finds relevant files and patterns
- Understands existing architecture
- Identifies integration points
- Discovers conventions
Reviews Memory
- Checks project plans
- Reads previous decisions
- Understands constraints
- Follows established patterns
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 contextUpdates Memory
# 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.tsWorkflow Examples
Feature Implementation Flow
# 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
# 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
# 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" --validateIntelligent 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
/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
/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
/execute-task "Set up Redis caching for API responses"- Configures infrastructure
- Integrates with application
- Adds monitoring
- Documents setup
4. Maintenance Tasks
/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
# 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 validationConditional Implementation
# Adaptive based on findings
/execute-task "Optimize search functionality based on usage patterns"
# Discovers:
# - Current search implementation
# - Usage analytics
# - Performance bottlenecks
# Then implements appropriate solutionCross-System Tasks
# Coordinated changes
/execute-task "Implement event-driven inventory updates across services"
# Updates:
# - Inventory service
# - Order service
# - Notification service
# - Event bus configurationIntegration 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
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"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"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
Ambiguous Requirements
- Prompt asks clarifying questions
- Suggests interpretations
- Provides options
- Documents assumptions
Technical Blockers
- Identifies constraints
- Suggests alternatives
- Documents blockers
- Proposes workarounds
Integration Conflicts
- Detects incompatibilities
- Resolves conflicts
- Updates dependencies
- Maintains stability
Tips
- Start with Context: Let the prompt discover before doing
- Be Specific: Clear requirements lead to better implementation
- Think in Steps: Break large tasks into smaller ones
- Validate Early: Use --validate flag for critical changes
- Document Decisions: The prompt captures why, not just what
