Implement
Execute a feature implementation pipeline: plan, implement, refactor, test, review, and document.
Claude CodeGeneric
---
allowed-tools: Bash(* !rm:*), WebFetch(domain:*), Agent(*)
description: "Execute a feature implementation pipeline: plan, implement, refactor, test, review, and document."
argument-hint: [feature_name]
---
## Execution vars
Pass these vars to the subagents:
- `feature_name` - the name of the feature to be implemented. $ARGUMENTS
# CRITICAL: This is a 6-step pipeline. You MUST execute ALL steps in order.
When this command is executed, you MUST run these 6 agents sequentially. Do NOT skip any step.
## Rules Reference
Consult the project rules in `.claude/rules/` for detailed conventions:
| Topic | Rule File |
|-------|-----------|
| **Architecture Overview** | `architecture.md` |
| **Coding Style** | `coding-style.md` |
| Domain Layer | `domain/domain.md`, `domain-entity.md`, `domain-repository.md`, `domain-value-object.md`, `domain-exception.md`, `domain-service.md` |
| Application Layer | `application/application.md`, `application-command.md`, `application-query.md` |
| Infrastructure Layer | `infrastructure/infrastructure.md`, `infrastructure-controller.md`, `infrastructure-repository.md` |
| Tests | `tests/tests.md`, `tests-unit.md`, `tests-functional.md`, `tests-mother.md` |
---
## STEP 1: Planning (REQUIRED)
**Say:** `[Claude Agent] Step 1/6: Activating Feature Planner...`
You MUST invoke the @feature-planner-agent agent to:
- Ask the user to describe the feature (if not already provided)
- Create a detailed implementation plan following DDD architecture
- Define API endpoints, Commands, Queries, Domain Events, and Value Objects
- Generate a Markdown prd.md plan ready for execution
- Create a plan file in `.claude/sessions/{feature_name}/prd.md` with the execution plan and its tasks
- Get user approval before proceeding to the next step
---
## STEP 2: Implementation (REQUIRED)
**Say:** `[Claude Agent] Step 2/6: Activating Feature Implementer...`
You MUST invoke the @feature-developer-agent agent to:
- Implement the plan task-by-task following layer order: Domain → Application → Infrastructure
- Use proper PHP types with `declare(strict_types=1)`
- Follow DDD patterns (Entities, Value Objects, Repository interfaces, Commands, Queries, Handlers)
- Use named constructors (`create()`/`make()`) for Entities
- Use Request DTOs with `#[Assert\*]` validation attributes
- Create Mother Objects for test data
**Do NOT proceed to Step 3 until all tasks are implemented.**
---
## STEP 3: Refactoring (REQUIRED)
**Say:** `[Claude Agent] Step 3/6: Activating Refactor Agent...`
You MUST invoke the @refactor-agent agent to:
- Review all changed files for code quality
- Ensure business logic is in Domain layer (not Controllers or Handlers)
- Ensure proper separation of concerns (Controller → Handler → Domain)
- Verify `final readonly class` for Commands, Queries, Handlers, Responses
- Verify `final class` for Entities and Controllers
- Replace magic strings with constants or enums
- Run quality checks: `make style && make test`
**Do NOT proceed to Step 4 until refactoring is complete and all checks pass. If there are errors, fix them and repeat Step 3.**
---
## STEP 4: Testing (REQUIRED)
**Say:** `[Claude Agent] Step 4/6: Activating Testing Agent...`
You MUST invoke the @unit-testing-agent agent to:
- Review test coverage with `make test/coverage`
- Add missing unit tests (happy path, error path, edge cases)
- Use PHPUnit with `#[Test]` attribute
- Follow test naming: `itShould{Action}{Condition}`
- Use GIVEN-WHEN-THEN comments
- Use Mother Objects for test data (not manual object creation)
- Use `createMock()` with `|MockObject` typing for dependencies
- Run full test suite: `make test`
- Run static analysis: `make static-analysis`
**Do NOT proceed to Step 5 until ALL tests pass and static analysis passes. If there are errors, go back to Step 3 and fix them.**
---
## STEP 5: Final Review (REQUIRED)
**Say:** `[Claude Agent] Step 5/6: Activating Final Reviewer...`
You MUST invoke the @code-reviewer-agent agent to:
- Verify all requirements are met
- Check DDD architecture compliance (layer dependencies)
- Verify security checklist (input validation via Request DTOs, auth, `#[\SensitiveParameter]`)
- Confirm test coverage meets standards
- Run all quality checks: `make style && make test`
- Provide final verdict: APPROVED or CHANGES REQUESTED
If CHANGES REQUESTED: go back to the appropriate step and fix issues.
---
## STEP 6: Documentation (REQUIRED)
**Say:** `[Claude Agent] Step 6/6: Activating Documentation Agent...`
You MUST invoke the @documentation-agent agent to:
- Analyze the implemented context and extract business logic
- Document the domain model (entities, value objects, relationships)
- Document all API endpoints with examples
- Document all use cases (commands/queries) with flow explanations
- Document error handling and exceptions
- Create comprehensive documentation at `docs/contexts/{context-name}/README.md`
- Ensure documentation is clear for new developers joining the team
**The documentation must answer:**
- What does this context do? (Business purpose)
- How does it work? (Technical flow)
- How do I use the API? (Endpoints with examples)
---
## Final Summary (REQUIRED)
After completing all 6 steps, display:
Feature Complete: [Name]
Pipeline Summary
- Step 1: Planning - DONE
- Step 2: Implementation - DONE
- Step 3: Refactoring - DONE
- Step 4: Testing - DONE
- Step 5: Final Review - APPROVED
- Step 6: Documentation - DONE
Files Changed
- Created: X files
- Modified: Y files
Tests
- Unit: X tests
- Functional: Y tests
- Status: All passing
Quality Checks
- PHPStan: Passed
- PHP CS Fixer: Passed
Documentation
- Location: docs/contexts/{context-name}/README.md
- Status: Generated
**IMPORTANT:** Respond in the user's language throughout the process.
---
### Available Subagents Reference
| Subagent | Use Case |
|----------|----------|
| `feature-planner-agent` | Plan features with DDD architecture, tasks, and
Maintain Implement?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[Implement on getagentictools](https://getagentictools.com/loops/sefhi-critical-this-is-a-6-step-pipeline-you-must-execute-all-steps-in-order?ref=badge)