Claude Code Feature Implementation Plan and Build from a Ticket with Repo Convention Discovery

Has Claude Code investigate how similar features are built in the repository, produce an implementation plan with acceptance tests, then implement it in verified increments. Surfaces risks, open questions, and next actions before and after coding.

You get: Working code with an explanation

More like this

The prompt

claude-code-feature-implementation-plan-and-build-from-a-ticket-with-repo-convention-discovery.md
Role: You are Claude Code acting as a senior engineer joining the repository at {repo_path}. You learn local conventions from the code itself, plan before building, and verify each increment.

Context: A new feature must be added. The decision this supports is whether the plan is sound enough to build now, and afterwards whether the implementation is ready for review. Read CLAUDE.md, README, architecture docs, and CI config first.

Task: Investigate, plan, get alignment on open questions, implement in small verified increments, and deliver a review-ready change.

Inputs (ask for any that are missing; list assumptions separately):
- Ticket or feature description: {feature_description}
- User-facing acceptance criteria: {acceptance_criteria}
- Tech stack and runtime versions: {tech_stack}
- Similar existing feature to mirror (optional): {reference_feature}
- Test, lint, and build commands: {verify_commands}
- Out of scope: {out_of_scope}
- Rollout constraints such as feature flags or migrations: {rollout_constraints}

Constraints:
- Phase 1 is read-only. Make no edits until the plan is presented and open questions are answered or assumptions are explicitly accepted.
- Follow conventions found in the code for naming, error handling, logging, and test layout. Cite the files you derived them from.
- Do not add dependencies, change CI, or modify {out_of_scope} without asking.
- Never fabricate APIs or library behavior. Check installed versions in lockfiles and read source or types before using a library.
- Do not include secrets or real user data in code or tests.
- Report only checks you ran; mark others as not run.

Workflow:
1. Restate the feature, assumptions, and missing information. Ask blocking questions.
2. Investigate: use Glob, Grep, and Read to find the entry points, data models, and tests for {reference_feature} or the closest analog. Record conventions with file references.
3. Plan: list the files to create or change, data and interface changes, test cases mapped to each acceptance criterion, migration or flag needs, and a sequence of increments.
4. Checkpoint: present the plan and wait for approval when there are blocking questions or high-risk changes.
5. Build increment by increment. After each, run the relevant tests, then {verify_commands} at the end. Write tests alongside the code.
6. Self-review the git diff against the plan and acceptance criteria. Remove debug code.
7. Document: update docs or changelog only where the repo convention requires it.

Output format:## Assumptions and Missing Information
## Codebase Findings (table: area | convention | evidence file)
## Implementation Plan (table: increment | files | change | tests | risk)
## Acceptance Criteria Traceability (criterion | test | status)
## Execution Log (increment | command | result | run: yes/no)
## Final Diff Summary
## Risks and Open Questions
## Rollout and Rollback Notes
## Next Actions (ordered checklist)

Acceptance criteria:
- Each user-facing acceptance criterion maps to at least one passing test.
- The change matches existing conventions, with cited evidence.
- No out-of-scope files or dependencies were changed.
- Lint, type-check, and tests pass, or failures are reported honestly with causes.
- Rollout and rollback steps are stated.

Quality checks before finishing:
- Did I verify every external API or library call against the installed version?
- Are error paths, empty states, permissions, and concurrency handled or listed as risks?
- Does anything in the diff not trace back to the plan?
- Are inferred statements labeled as inferred?

Example output

AI-written example

Assumptions and Missing Information

  • Feature: GET /v1/reports/low-stock.csv returns items where quantity <= reorder_threshold for the caller's warehouse.
  • Assumed (accepted at checkpoint): the default limit is 10,000 rows, and the CSV is streamed.
  • Inferred: the reports:read permission already exists, because the orders export uses it.
  • Node 20.11, Express 4.19, Prisma 5.14, Vitest 1.6 (from package-lock.json).

Codebase Findings

AreaConventionEvidence file
RoutingOne router per resource, mounted in routes/index.tssrc/routes/orders-export.ts
ErrorsThrow AppError(code, status); middleware formats itsrc/lib/errors.ts
Logginglogger.child({ route }), no row data loggedsrc/routes/orders-export.ts
Flagsconfig.flags.*, read from envsrc/config/flags.ts
Teststest/routes/*.test.ts using the buildApp() helpertest/routes/orders-export.test.ts

Implementation Plan

#FilesChangeTestsRisk
1src/config/flags.tsAdd lowStockExport flag, default offflag-off returns 404Low
2src/services/low-stock.tsPrisma query with cursor paginationunit: threshold boundary, emptyMedium (query cost)
3src/routes/low-stock-export.tsStream CSV and apply the permission check200, 403, empty CSVMedium
4docs/api.mdDocument endpointnoneLow

Acceptance Criteria Traceability

CriterionTestStatus
Only items at or below threshold are exportedlow-stock.test.ts › boundaryPass
Users without reports:read get 403low-stock-export.test.ts › forbiddenPass
Empty result returns header-only CSVlow-stock-export.test.ts › emptyPass

Execution Log

IncrementCommandResultRun
1npx vitest run test/config4 passedyes
2npx vitest run test/services/low-stock.test.ts5 passedyes
3npx vitest run test/routes/low-stock-export.test.ts6 passedyes
Finalnpm run lint && npm run typecheck && npm test0 errors, 212 passedyes
Finalnpm run test:e2eNot run (requires a seeded DB)no

Final Diff Summary

4 files added and 3 modified, with no new dependencies. Core handler:

router.get("/low-stock.csv", requirePerm
Generated from this prompt by AI. Your results will vary.

Tips and common edits

Works best when acceptance criteria are concrete and testable. Provide a reference feature to speed up convention discovery. In Claude Code, you can approve the plan at the checkpoint before edits begin. For large features, split the ticket and run the prompt once per slice.

Questions about this prompt

More in Claude Code

Claude Code Behavior-Preserving Refactor with Characterization Tests and Staged Commits

Guides Claude Code to refactor a module safely by first pinning current behavior with characterization tests, then applying small reversible steps with verification after each. Delivers a diff, risk register, and rollback plan.

Claude Code Plan-Then-Implement a Feature With Approval Checkpoints

Makes Claude Code explore the repo, write a step-by-step plan for your approval, then build the feature in small verified steps, stopping at each checkpoint for your go-ahead.

Claude Code Root-Cause Bug Investigation with Failing Test and Minimal Patch

Directs Claude Code to reproduce a bug, trace it to a root cause using repository evidence, write a failing regression test, and apply the smallest safe fix. Ends with a verified diff, risks, and next actions.

Lean CLAUDE.md Generator from Repo Inspection

Claude Code inspects your repository and writes a CLAUDE.md under 200 lines with verified commands first, checkable conventions, anti-patterns and the reasons behind key decisions.

Agent Run Post-Mortem: Trace Root Cause and Prompt or Tool Fixes

Analyzes a pasted agent trace to find the first real failure and proposes exact prompt rewrites or tool changes, each with a test.

Characterization Tests Before a Refactor

Writes tests that lock in a module's current behavior, including edge cases and quirks, so you can refactor safely.

Checkpoint and Rollback Manager with Compensation Steps and Failure Injection Tests

Guides Claude Code to implement checkpoint snapshots, rollback modes, and compensating actions for side-effecting agent phases, then prove them with failure-injection tests. Helps you decide the rollback strategy per phase.

Claude Code Hook Writer: Auto-Run Lint, Typecheck or Tests After Edits

Produces a PostToolUse hook entry for settings.json, the script it calls and a concrete procedure to test that the check runs after file edits.

Codebase Tour for a Specific Task

Explores a repo through the lens of your task and explains the architecture, key files and data flow, then says where to start.

Coding Agent Task Brief with Guardrails, Test Plan, and Rollback Steps

Creates a scoped brief for an AI coding agent that limits file changes, defines tests, and includes a rollback plan and review checklist.

Custom Slash Command Builder for Repeated Claude Code Tasks

Turns a task you repeat into a custom slash command file with frontmatter, arguments, restricted allowed tools and a fixed output format.

DAG Scheduler with Fan-Out/Fan-In Barriers and Resumable Run Ledger for Agent Pipelines

Guides Claude Code to build or refactor a dependency-aware DAG scheduler for agent phases, with cycle validation, bounded parallelism, join policies, retries, and an append-only run ledger so interrupted runs resume without redoing finished nodes.