Overview
The Code-Executor is GemKit's workhorse implementation agent, designed for plan-driven, test-driven development. Unlike generic coding assistants, Code-Executor follows a disciplined methodology: understand the task, create a plan, implement incrementally, verify with tests, and iterate based on feedback. Whether you're building a new feature from scratch, refactoring legacy code, or fixing complex bugs, Code-Executor brings structure and reliability to AI-assisted development.
Core Philosophy:
- Plan before code - Never rush into implementation without a clear strategy
- Test-driven development - Write tests to validate behavior
- Incremental implementation - Build step-by-step, verify each step
- Self-verification - Run tests and checks before considering work complete
When to Use Code-Executor
✅ Ideal Use Cases
Feature Implementation
- New API endpoints with full CRUD operations
- React components with state management
- Database models and migrations
- Authentication and authorization systems
Refactoring Tasks
- Modernizing legacy code patterns
- Extracting reusable components
- Improving code organization
- Performance optimizations
Bug Fixes
- Issues with clear reproduction steps
- Regression fixes requiring tests
- Type errors and lint violations
- Integration problems
Code Migrations
- Framework upgrades (React 17 → 19)
- Library replacements (Axios → Fetch)
- API version migrations
- Database schema changes
❌ Not Ideal For
Open-ended Research → Use Researcher agent instead
- Technology comparisons
- Best practices exploration
- Architecture decisions
Test-Only Tasks → Use Tester agent instead
- Generating tests for existing code
- Coverage analysis
- Test suite improvements
Quick Experiments → Use direct AI chat
- Proof of concepts
- Throwaway prototypes
- Learning exercises
Spawning Code-Executor
Basic Usage
What happens:
- Agent analyzes the prompt and breaks down requirements
- Creates an implementation plan with phases
- Implements code following plan steps
- Writes tests to verify functionality
- Runs tests and reports results
- Provides summary of changes
With Skills
Skills inject domain-specific knowledge and patterns into the agent's context.
Available skills:
frontend-development- React 19, TanStack, MUI v7, Zustand, Vitestbackend-development- Node.js, Python, APIs, OAuth, PostgreSQLfrontend-design- UI/UX, CSS, animationstesting- Vitest, Jest, Playwright, MSW
With Context
Provide relevant files to guide implementation and ensure consistency.
Context best practices:
- Include only directly relevant files (reduces token usage)
- Provide type definitions for better accuracy
- Include related configuration files when needed
- Avoid entire directories unless necessary
With Model Selection
Choose the right model based on task complexity.
Real-World Scenarios
Scenario 1: Implementing a React Component
Task: Create a user profile card with avatar, bio, and edit functionality.
Expected workflow:
-
Planning Phase (agent creates mental plan):
markdown -
Implementation:
- Creates
src/components/UserProfileCard.tsx - Imports User type from existing
src/types/user.ts - Uses existing Avatar component
- Implements responsive design with MUI Grid
- Adds state management with Zustand
- Creates
-
Testing:
- Creates
src/components/UserProfileCard.test.tsx - Tests rendering with mock data
- Tests loading state
- Tests error handling
- Tests edit button interaction
- Creates
-
Verification:
- Runs tests:
npm run test UserProfileCard - Reports results: "✓ All 5 tests passed"
- Runs tests:
Output files:
src/components/UserProfileCard.tsx(142 lines)src/components/UserProfileCard.test.tsx(78 lines)src/stores/profileStore.ts(optional, if needed)
Scenario 2: Adding an API Endpoint
Task: Create a REST API endpoint for user settings management.
Expected workflow:
-
Planning Phase:
markdown -
Implementation:
src/types/settings.ts- TypeScript interfacessrc/models/UserSettings.ts- Database modelsrc/controllers/settingsController.ts- Business logicsrc/validators/settings.ts- Zod schemassrc/routes/settings.ts- Express routes- Updates
src/routes/index.tsto register routes
-
Testing:
tests/integration/settings.test.ts- Full E2E tests- Tests all CRUD operations
- Tests authentication requirements
- Tests validation errors
- Tests edge cases
-
Verification:
- Runs integration tests
- Tests actual HTTP requests
- Verifies database operations
Output summary:
Scenario 3: Refactoring Legacy Code
Task: Modernize class-based React components to functional components with hooks.
Expected workflow:
-
Planning Phase:
markdown -
Implementation:
- Converts
Dashboard.jsx→Dashboard.tsx - Replaces
this.statewithuseState - Replaces lifecycle methods with
useEffect - Adds TypeScript types
- Preserves all existing functionality
- Converts
-
Testing:
- Creates comprehensive tests for refactored components
- Tests match original behavior
- Adds regression tests
-
Verification:
- Compares old vs. new behavior
- Ensures no breaking changes
Before (Dashboard.jsx):
After (Dashboard.tsx):
Scenario 4: Fixing a Bug with Tests
Task: Fix authentication bug where tokens expire but UI doesn't reflect it.
Expected workflow:
-
Planning Phase:
markdown -
Implementation:
- Fixes token validation in
src/middleware/authenticate.ts - Adds refresh token logic to
src/services/auth.ts - Updates
src/hooks/useAuth.tsto handle expiry - Adds Axios interceptor for 401 responses
- Implements auto-redirect to login
- Fixes token validation in
-
Testing:
- Tests token expiry detection
- Tests refresh token flow
- Tests 401 response handling
- Tests redirect behavior
- Tests edge cases (network failure during refresh)
-
Verification:
- Runs all auth tests
- Manually tests expiry scenario
- Confirms bug is fixed
Scenario 5: Building a Feature End-to-End
Task: Complete user registration with email verification.
Expected workflow:
-
Planning Phase (detailed multi-step plan):
markdown -
Implementation (creates 12+ files):
- Backend: models, controllers, services, routes
- Frontend: components, hooks, API clients
- Email: templates, service integration
- Config: environment variables
-
Testing (comprehensive test suite):
- Backend unit tests (token generation, validation)
- API integration tests (registration, verification)
- Frontend component tests
- E2E test (complete user journey)
-
Verification:
- Runs full test suite
- Reports coverage
- Lists all created/modified files
Output:
The /code Workflow Integration
The Code-Executor is the core agent in the /code workflow, which orchestrates a complete development cycle:
Workflow phases:
-
Research (Researcher agent spawned)
- Investigates best practices
- Identifies patterns and libraries
- Documents recommendations
-
Planning (Code-Executor in plan mode)
- Reviews research findings
- Creates implementation plan
- Defines acceptance criteria
-
Implementation (Code-Executor)
- Executes plan step-by-step
- Writes production code
- Maintains consistency
-
Verification (Tester agent spawned)
- Generates comprehensive tests
- Runs test suite
- Reports coverage
When to use /code workflow vs. direct Code-Executor:
- Use /code: For complete features requiring research and testing
- Use Code-Executor directly: When you already know the approach and just need implementation
Best Practices
1. Provide Clear Acceptance Criteria
2. Include Relevant Context
3. Let the Agent Plan First
Don't micromanage—trust the planning process:
4. Review Before Accepting Changes
Always review generated code:
5. Use Appropriate Models
6. Iterate Based on Feedback
Customizing the Agent
You can modify the Code-Executor agent definition to match your team's needs:
File: .gemini/agents/code-executor/agent.md
Activate customized agent:
Troubleshooting
Agent Makes Incorrect Assumptions
Problem: Generated code doesn't match expected architecture.
Solution:
Implementation Differs from Expectation
Problem: Code works but uses different approach than you wanted.
Solution:
Tests Fail After Implementation
Problem: Agent completes but tests don't pass.
Solution:
Agent Tries to Modify Too Many Files
Problem: Agent wants to refactor unrelated code.
Solution:
Related Documentation
- Tester Agent Guide - Comprehensive testing
- Researcher Agent - Pre-implementation research
- Multi-Agent Orchestration - Coordinating agents
- Skills Reference - Available skills
- Workflows - Understanding /code and custom workflows
- Creating Custom Agents - Customization guide
Summary
The Code-Executor agent is your reliable implementation partner, bringing structure and discipline to AI-assisted development. By following a plan-driven, test-driven methodology, it ensures quality and maintainability while significantly accelerating development velocity. Use it for feature implementation, refactoring, bug fixes, and migrations—any task where structured, verified code generation is needed.
Key takeaways:
- Always provide clear requirements and acceptance criteria
- Include relevant context files for better accuracy
- Trust the planning process—don't micromanage
- Review generated code before accepting
- Use appropriate models based on complexity
- Customize agent definition for team standards
- Iterate based on feedback and results