Create structured implementation plans for features, fixes, and refactors. Use when the user asks to plan, design an approach, break down a task, or is in plan mode. Enforces reuse-first, math correctness, file size limits, DDD naming, and test planning.
Produce structured, actionable implementation plans that enforce engineering discipline before any code is written.
Before planning any new code, search the codebase for existing helpers, utilities, patterns, or similar implementations. Plans must explicitly list:
Duplication is a planning failure. Best engineers factor out and reuse similar code.
Always write clean code, but NEVER simplify mathematical formulas, algorithms, or numerical logic for the sake of readability.
Every new or modified file must stay under 600 lines. If a plan would push a file over the limit, include a refactoring step to split by responsibility -- not arbitrarily.
All classes, functions, variables, and files must use real-world domain names that match the business domain:
WeeklyReturnForecast, not ModelOutputAllocationWeight, not resultHalalScreeningDecision, not itemOrderIdempotencyKey, not keyPlans must call out naming choices for all new entities.
Understand the "what" and "why". Clarify ambiguity before proceeding.
Search the codebase for:
List reusable pieces explicitly in the plan output.
Identify all affected:
Verify the plan respects architecture boundaries (reference Agent.md):
Evaluate:
Order tasks by dependencies. Identify parallelizable work.
Create actionable, sequenced steps. For each task:
For every feature or change, plan which tests to write or update:
min_items, max_items, min/max length via API calls. Never write schema-only tests.Check the plan against non-negotiable invariants:
run_id = paper:YYYY-MM-DD, attempt starts at 1client_order_id format: paper:YYYY-MM-DD:attempt-<N>:<SYMBOL>:<SIDE>Reference Agent.md for full details on:
persist_result=True, task retries)Every plan must follow this structure:
## Goal
<What and why>
## Reuse Inventory
- <existing_module.function> -- reuse for <purpose>
- <existing_pattern> -- extend for <purpose>
- (genuinely new: <list>)
## Impact Analysis
- Files affected: ...
- APIs affected: ...
- Data/storage affected: ...
## Approach
<High-level design with naming choices for new entities>
## Tasks
1. <task> -- file: <path>, reuse: <what>, new: <what>
- [ ] Implementation
- [ ] Tests: <what to test>
2. ...
## Test Plan
- Unit tests: <list with coverage targets>
- Integration tests: <list with API calls to make>
- Edge cases: <specific scenarios>
## Risks
- <risk and mitigation>
## Cleanup (always include)
- [ ] Fix all ruff linting issues (related and unrelated to the change)
- [ ] Run and fix all tests (related and unrelated to the change)