|
| 1 | +# Adopting Spec Kit in an Existing Project |
| 2 | + |
| 3 | +You do not need to recreate an existing system from specifications before using |
| 4 | +Spec Kit. Initialize the repository in place, capture the rules that matter, |
| 5 | +and use the workflow for the next bounded change. |
| 6 | + |
| 7 | +## 1. Start from a Reviewable Baseline |
| 8 | + |
| 9 | +Before initialization, commit or stash existing work and create a branch for the |
| 10 | +adoption. This makes every generated file visible in a normal code review. |
| 11 | + |
| 12 | +Choose the [integration key](../reference/integrations.md) for the coding agent |
| 13 | +you use. Then run the command from the repository root: |
| 14 | + |
| 15 | +```bash |
| 16 | +specify init --here --force --integration <key> |
| 17 | +``` |
| 18 | + |
| 19 | +`--here` targets the current directory. `--force` allows initialization in a |
| 20 | +non-empty directory and may replace files at conflicting managed paths, so use |
| 21 | +it only after creating a reviewable baseline. It does not delete the rest of |
| 22 | +your application. |
| 23 | + |
| 24 | +Review the resulting diff before continuing. Initialization adds the shared |
| 25 | +`.specify/` project files and the command or skill files required by your |
| 26 | +selected integration. It does not rewrite your application or infer |
| 27 | +specifications for existing behavior. |
| 28 | + |
| 29 | +> [!NOTE] |
| 30 | +> Git initialization and feature branches are optional and are managed by the |
| 31 | +> **git** extension. Add it with `specify extension add git` if you want that |
| 32 | +> workflow. |
| 33 | +
|
| 34 | +## 2. Capture Project Guardrails |
| 35 | + |
| 36 | +Run `/speckit.constitution` with principles that are already true for the |
| 37 | +repository or that the team has explicitly agreed to adopt: |
| 38 | + |
| 39 | +```text |
| 40 | +/speckit.constitution Preserve public API compatibility. Follow the existing |
| 41 | +service boundaries. Every database migration must include a rollback plan. |
| 42 | +Run the repository's established unit and integration test suites. |
| 43 | +``` |
| 44 | + |
| 45 | +Use the repository's README, architecture decisions, contribution guide, and |
| 46 | +CI configuration as evidence. Do not invent standards merely to fill the |
| 47 | +constitution template. The constitution governs later planning and analysis, |
| 48 | +so unrealistic rules create noise instead of useful constraints. |
| 49 | + |
| 50 | +## 3. Choose a Bounded First Change |
| 51 | + |
| 52 | +Start with a feature, bug fix, or modernization slice that can be reviewed |
| 53 | +independently. Do not make "document the entire existing system" your first |
| 54 | +feature unless that inventory is itself the intended deliverable. |
| 55 | + |
| 56 | +Describe both the requested outcome and the compatibility boundaries that must |
| 57 | +remain intact: |
| 58 | + |
| 59 | +```text |
| 60 | +/speckit.specify Add CSV export to the existing orders page. Preserve current |
| 61 | +filters and authorization behavior. Export only the rows visible to the signed-in |
| 62 | +user, and do not change the existing JSON API response. |
| 63 | +``` |
| 64 | + |
| 65 | +The codebase remains implementation context. The new `spec.md` defines the |
| 66 | +change you intend to make, not a retroactive specification of every existing |
| 67 | +behavior. |
| 68 | + |
| 69 | +## 4. Plan Against the Repository |
| 70 | + |
| 71 | +Continue through the normal workflow: |
| 72 | + |
| 73 | +1. Run `/speckit.clarify` to resolve uncertain behavior and compatibility |
| 74 | + requirements. |
| 75 | +2. Run `/speckit.plan` and verify that the proposed design reuses the existing |
| 76 | + architecture, dependencies, and test conventions. |
| 77 | +3. Run `/speckit.tasks`, then `/speckit.analyze` to check consistency before |
| 78 | + implementation. |
| 79 | +4. Run `/speckit.implement` and review code and artifact changes together. |
| 80 | +5. Run `/speckit.converge` to find remaining gaps. If it adds tasks, repeat |
| 81 | + implementation and convergence until the feature is complete. |
| 82 | + |
| 83 | +For command details and optional quality gates, see the |
| 84 | +[Quick Start Guide](../quickstart.md) and |
| 85 | +[Agentic SDD reference](../reference/agentic-sdd.md). |
| 86 | + |
| 87 | +## 5. Decide How Specs Will Age |
| 88 | + |
| 89 | +After the first change, agree on how the team will maintain completed feature |
| 90 | +artifacts: |
| 91 | + |
| 92 | +- Keep each feature directory as an immutable historical record. |
| 93 | +- Maintain `spec.md` as a living contract and regenerate downstream artifacts. |
| 94 | +- Allow discoveries to flow back from code, tasks, or plans, then reconcile the |
| 95 | + full artifact set. |
| 96 | + |
| 97 | +The [Spec Persistence Models](../concepts/spec-persistence.md) page compares |
| 98 | +these choices. The [Evolving Specs guide](evolving-specs.md) provides the |
| 99 | +maintenance loop for each model. |
| 100 | + |
| 101 | +## Existing-Project Examples |
| 102 | + |
| 103 | +The [community walkthroughs](../community/walkthroughs.md) include brownfield |
| 104 | +examples across .NET, Java, and Go/React codebases. Community extensions for |
| 105 | +architecture discovery and brownfield bootstrapping are listed in the |
| 106 | +[extension catalog](../community/extensions.md). |
0 commit comments