@x0rium/devkit-cli 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/diff.d.ts +35 -0
  2. package/dist/diff.d.ts.map +1 -0
  3. package/dist/diff.js +154 -0
  4. package/dist/diff.js.map +1 -0
  5. package/dist/index.js +101 -2
  6. package/dist/index.js.map +1 -1
  7. package/dist/scaffold.d.ts +1 -0
  8. package/dist/scaffold.d.ts.map +1 -1
  9. package/dist/scaffold.js +42 -4
  10. package/dist/scaffold.js.map +1 -1
  11. package/package.json +3 -2
  12. package/skills/arch-kit/README.md +195 -0
  13. package/skills/arch-kit/SKILL.md +128 -0
  14. package/skills/arch-kit/references/adr.md +25 -0
  15. package/skills/arch-kit/references/impact.md +13 -0
  16. package/skills/arch-kit/references/invariants.md +9 -0
  17. package/skills/arch-kit/references/investigation.md +37 -0
  18. package/skills/arch-kit/references/rfc.md +36 -0
  19. package/skills/devkit-init/SKILL.md +99 -0
  20. package/skills/devkit-init/references/brownfield.md +147 -0
  21. package/skills/devkit-init/references/greenfield.md +44 -0
  22. package/skills/devkit-init/references/upgrade.md +103 -0
  23. package/skills/product-kit/README.md +135 -0
  24. package/skills/product-kit/SKILL.md +101 -0
  25. package/skills/product-kit/references/roadmap.md +16 -0
  26. package/skills/product-kit/references/users.md +14 -0
  27. package/skills/product-kit/references/ux_invariants.md +8 -0
  28. package/skills/qa-kit/README.md +188 -0
  29. package/skills/qa-kit/SKILL.md +113 -0
  30. package/skills/qa-kit/references/assumption_checks.md +10 -0
  31. package/skills/qa-kit/references/coverage_map.md +19 -0
  32. package/skills/qa-kit/references/test_contracts.md +10 -0
  33. package/skills/research-kit/README.md +139 -0
  34. package/skills/research-kit/SKILL.md +84 -0
  35. package/skills/research-kit/references/assumptions.md +9 -0
  36. package/skills/research-kit/references/feasibility.md +15 -0
  37. package/skills/research-kit/references/market.md +13 -0
  38. package/skills/research-kit/references/unknowns.md +9 -0
  39. package/skills/spec-kit/README.md +139 -0
  40. package/skills/spec-kit/SKILL.md +108 -0
@@ -0,0 +1,195 @@
1
+ # ArchKit
2
+
3
+ > Уровень 3. "Как это устроено технически?"
4
+
5
+ ---
6
+
7
+ ## Когда использовать
8
+
9
+ - ProductKit завершён, UX инварианты зафиксированы
10
+ - нужно выбрать архитектуру из нескольких вариантов
11
+ - нужно формализовать технические инварианты
12
+ - нужно верифицировать архитектуру до написания кода
13
+ - нужно сгенерировать constitution.md для SpecKit
14
+
15
+ ---
16
+
17
+ ## Ключевая идея
18
+
19
+ Архитектура описывается декларативно — не "как реализовать" а "что гарантировать". Верификация происходит до написания кода. SpecKit получает на вход не догадки а доказанное основание.
20
+
21
+ ---
22
+
23
+ ## Фазы
24
+
25
+ ### Phase 1: Discovery
26
+ ```
27
+ QUESTIONS:
28
+ - Какие quality attributes критичны? (reliability, performance, security)
29
+ - Что хуже: потерять данные или показать устаревшие?
30
+ - Какая нагрузка? Какие пики?
31
+ - Один разработчик или команда?
32
+ - Где хостим?
33
+
34
+ FORBIDDEN:
35
+ - предлагать конкретные технологии
36
+ - выбирать стек
37
+ ```
38
+
39
+ ### Phase 2: Architecture Variants
40
+ ```
41
+ AI предлагает 2-3 варианта с явными трейдоффами.
42
+ Каждый вариант — ADR с:
43
+ - что выбираем
44
+ - почему именно это
45
+ - от чего отказываемся и почему
46
+ - риски выбора
47
+
48
+ FORBIDDEN:
49
+ - предлагать один вариант как единственный
50
+ - скрывать трейдоффы
51
+ - выбирать за разработчика
52
+ ```
53
+
54
+ ### Phase 3: Specification
55
+ ```
56
+ Выбранная архитектура формализуется:
57
+ - компоненты и их контракты
58
+ - технические инварианты
59
+ - failure modes и как обрабатываются
60
+ - явные UNKNOWN которые блокируют разработку
61
+ ```
62
+
63
+ ### Phase 4: Verification
64
+ ```
65
+ Adversarial scenarios — AI играет роль враждебной среды:
66
+ - что если этот сервис упал в момент транзакции?
67
+ - что если два запроса пришли одновременно?
68
+ - что если внешний сервис недоступен?
69
+
70
+ Для каждого сценария архитектура даёт ответ.
71
+ Если ответа нет — OPEN_QUESTION, блокирует переход.
72
+
73
+ Уровни верификации:
74
+ L1: структурная (зависимости, интерфейсы, нет циклов)
75
+ L2: сценарная (adversarial scenarios, AI симуляция)
76
+ L3: формальная (TLA+/Alloy для критических инвариантов, опционально)
77
+ ```
78
+
79
+ ---
80
+
81
+ ## События которые обрабатывает ArchKit
82
+
83
+ ### RFC (Request for Change)
84
+ Triggered: когда новые требования затрагивают инварианты
85
+ ```markdown
86
+ # RFC-XXX: [название]
87
+
88
+ TRIGGER: что изменилось
89
+ AFFECTED_INVARIANTS: [список]
90
+ AFFECTED_SPECS: [список]
91
+ COST: оценка стоимости изменения
92
+
93
+ OPTIONS:
94
+ A: ...
95
+ B: ...
96
+
97
+ DECISION: [выбранный вариант]
98
+ RATIONALE: почему
99
+ STATUS: open / accepted / rejected
100
+ ```
101
+
102
+ ### Investigation (технический блокер)
103
+ Triggered: баг в либе / провал бенчмарка / неожиданное ограничение
104
+ ```markdown
105
+ # Investigation-XXX: [название]
106
+
107
+ TRIGGER: что произошло
108
+ AFFECTED_ASSUMPTION: [ADR который сломался]
109
+ FINDING: что обнаружили
110
+
111
+ OPTIONS:
112
+ A: ...
113
+ B: ...
114
+ C: ...
115
+
116
+ DECISION: [выбранный вариант]
117
+ INVARIANTS_AFFECTED: none / [список]
118
+ SPECS_AFFECTED: [список]
119
+ TECHNICAL_DEBT: none / [описание]
120
+ STATUS: open / resolved
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Артефакты
126
+
127
+ ### invariants.md
128
+ ```markdown
129
+ # Technical Invariants
130
+
131
+ ## I1: [название]
132
+ STATEMENT: что система гарантирует
133
+ RATIONALE: почему это важно
134
+ VERIFICATION: как доказать / проверить
135
+ FAILURE_MODE: что происходит при нарушении
136
+ STATUS: verified / assumed / unverified
137
+ ```
138
+
139
+ ### impact.md
140
+ ```markdown
141
+ # Impact Map
142
+
143
+ Карта зависимостей между архитектурными решениями.
144
+ Используется для impact analysis при RFC и Investigation.
145
+
146
+ ## [Компонент / Решение]
147
+ DEPENDS_ON: [список]
148
+ DEPENDED_BY: [список]
149
+ INVARIANTS: [список инвариантов которые затрагивает]
150
+ ```
151
+
152
+ ### decisions/
153
+ ```
154
+ ADR-XXX.md ← Architecture Decision Records
155
+ RFC-XXX.md ← Request for Change
156
+ INV-XXX.md ← Investigation
157
+ ```
158
+
159
+ ### constitution.md
160
+ ```
161
+ Генерируется автоматически из invariants.md и decisions/.
162
+ Это входной артефакт для SpecKit.
163
+ НЕ редактировать вручную.
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Переход к SpecKit
169
+
170
+ **ALLOWED** когда:
171
+ - все adversarial scenarios имеют ответ
172
+ - нет OPEN_QUESTIONS без resolution
173
+ - все инварианты имеют статус verified или assumed с явным риском
174
+ - constitution.md сгенерирован
175
+
176
+ **BLOCKED** когда:
177
+ - есть OPEN_QUESTIONS блокирующего типа
178
+ - инварианты противоречат UX инвариантам из ProductKit
179
+ - не все failure modes описаны для критических путей
180
+
181
+ ---
182
+
183
+ ## Команды
184
+
185
+ ```
186
+ /arch init
187
+ /arch discovery
188
+ /arch variants
189
+ /arch specify
190
+ /arch verify
191
+ /arch rfc "описание изменения"
192
+ /arch investigate "описание блокера"
193
+ /arch generate-constitution
194
+ /arch status
195
+ ```
@@ -0,0 +1,128 @@
1
+ ---
2
+ name: arch-kit
3
+ description: DevKit Level 3. Use after ProductKit to explore architecture variants, establish technical invariants, verify system design, and generate constitution.md for SpecKit. Also triggers on architectural events during development: new requirements touching invariants (RFC), technical blockers like library bugs or benchmark failures (Investigation), or any change that affects system guarantees.
4
+ license: MIT
5
+ metadata:
6
+ author: devkit
7
+ version: "1.0"
8
+ layer: "3-of-5"
9
+ prev: product-kit
10
+ next: spec-kit
11
+ ---
12
+
13
+ # ArchKit — Level 3: "How is this technically structured?"
14
+
15
+ You are operating in ArchKit phase. Your job is to explore architecture options, establish technical invariants, verify the design, and produce a verified foundation for SpecKit.
16
+
17
+ ## Your Role
18
+
19
+ - Explore multiple architecture variants with explicit tradeoffs
20
+ - Establish technical invariants the system must guarantee
21
+ - Run adversarial verification before any code is written
22
+ - Generate constitution.md for SpecKit
23
+ - Handle RFC and Investigation events during development
24
+
25
+ ## FORBIDDEN at This Phase
26
+
27
+ - Writing implementation code
28
+ - Choosing FOR the developer between variants
29
+ - Hiding tradeoffs
30
+ - Moving to SpecKit while OPEN_QUESTIONS exist
31
+
32
+ ## Phases
33
+
34
+ ### Phase 1: Discovery
35
+ Before proposing any architecture, understand constraints. Ask:
36
+ - What quality attributes matter most? (reliability, performance, simplicity, security)
37
+ - What is worse: losing data or showing stale data?
38
+ - Expected load and growth?
39
+ - Team size?
40
+ - Hosting constraints?
41
+
42
+ Do NOT suggest technologies yet.
43
+
44
+ ### Phase 2: Architecture Variants
45
+ Propose 2–3 variants. Each must include:
46
+ - What we choose
47
+ - Why this fits the constraints
48
+ - What we give up (explicit tradeoffs)
49
+ - Risks of this choice
50
+
51
+ Never present one option as the only option.
52
+
53
+ ### Phase 3: Specification
54
+ Formalize the chosen architecture:
55
+ - Components and their contracts
56
+ - Technical invariants (what the system guarantees)
57
+ - Failure modes and how each is handled
58
+ - Explicit OPEN_QUESTIONS that block progress
59
+
60
+ ### Phase 4: Adversarial Verification
61
+ Play the role of a hostile environment. For every critical path, ask:
62
+ - What if this service crashes mid-transaction?
63
+ - What if two requests arrive simultaneously?
64
+ - What if the external service is down for 2 hours?
65
+ - What if the queue fills up?
66
+
67
+ Each scenario must have an answer. No answer = OPEN_QUESTION = blocks SpecKit.
68
+
69
+ Verification levels:
70
+ - L1: Structural (no circular deps, all interfaces defined, no unknowns)
71
+ - L2: Scenario (adversarial simulation, all failure modes handled)
72
+ - L3: Formal (TLA+/Alloy for critical invariants — optional, for high-stakes systems)
73
+
74
+ ## Artifacts to Produce
75
+
76
+ Read templates from:
77
+ - [Invariants template](references/invariants.md)
78
+ - [ADR template](references/adr.md)
79
+ - [RFC template](references/rfc.md)
80
+ - [Investigation template](references/investigation.md)
81
+ - [Impact map template](references/impact.md)
82
+
83
+ Save to `.devkit/arch/`.
84
+ Generate `.devkit/arch/constitution.md` → copy to `.specify/constitution.md`.
85
+
86
+ ## Event Detection During SpecKit
87
+
88
+ ### RFC Trigger
89
+ Developer says: "we also need X", "the client wants Y", "what if we add Z"
90
+
91
+ Check invariants.md. If any invariant is touched:
92
+ > "This touches invariant [I_N]. I'm stopping SpecKit and opening an RFC.
93
+ > Here's what's affected and the cost of the change."
94
+
95
+ Create `arch/decisions/RFC-XXX.md`. Run delta ArchKit cycle. Resume SpecKit only after RFC is resolved.
96
+
97
+ ### Investigation Trigger
98
+ Developer says: "found a bug in lib X", "benchmark failed", "this doesn't work as expected", "library doesn't support Y"
99
+
100
+ Check which ADR this breaks:
101
+ > "This breaks assumption in [ADR-N]. Opening Investigation."
102
+
103
+ Create `arch/decisions/INV-XXX.md`. Present options with costs. Developer decides. Update affected specs.
104
+
105
+ ## Gate: When Can We Move to SpecKit?
106
+
107
+ ALLOWED when:
108
+ - All adversarial scenarios have answers
109
+ - No OPEN_QUESTIONS of blocking type remain
110
+ - All invariants are `verified` or `assumed` with explicit risk noted
111
+ - UX invariants from ProductKit are not violated
112
+ - constitution.md generated
113
+
114
+ BLOCKED when:
115
+ - Any blocking OPEN_QUESTION is unresolved
116
+ - Invariants conflict with UX invariants
117
+ - Critical failure modes are unaddressed
118
+
119
+ ## Handoff
120
+
121
+ ```
122
+ ARCHITECTURE VERIFIED
123
+ VARIANT CHOSEN: [name and one-line rationale]
124
+ INVARIANTS: N verified, M assumed (risks noted)
125
+ OPEN_QUESTIONS: none / [list with owners]
126
+ CONSTITUTION: generated at .specify/constitution.md
127
+ READY FOR: SpecKit
128
+ ```
@@ -0,0 +1,25 @@
1
+ # Architecture Decision Record Template
2
+
3
+ ## ADR-XXX: [title]
4
+ DATE:
5
+ STATUS: proposed / accepted / superseded / rejected
6
+
7
+ ## Context
8
+ What situation requires a decision?
9
+
10
+ ## Decision
11
+ What we chose.
12
+
13
+ ## Rationale
14
+ Why this over alternatives.
15
+
16
+ ## Alternatives Considered
17
+ | Option | Why rejected |
18
+ |--------|-------------|
19
+
20
+ ## Consequences
21
+ What becomes easier. What becomes harder. What risks we accept.
22
+
23
+ ## Assumptions
24
+ What must be true for this decision to hold.
25
+ [These become targets for Investigation if they break]
@@ -0,0 +1,13 @@
1
+ # Impact Map Template
2
+
3
+ ## [Component or Decision Name]
4
+ DEPENDS_ON: [list of components/decisions it depends on]
5
+ DEPENDED_BY: [list of components/decisions that depend on it]
6
+ INVARIANTS: [invariants from invariants.md this touches]
7
+ SPECS: [spec files that implement this]
8
+
9
+ ## How to Use
10
+ When RFC or Investigation opens, query this map:
11
+ "What depends on [changed thing]?" → everything in DEPENDED_BY
12
+ "What does [changed thing] depend on?" → everything in DEPENDS_ON
13
+ This gives the full blast radius before any decision is made.
@@ -0,0 +1,9 @@
1
+ # Technical Invariants Template
2
+
3
+ ## I1: [name]
4
+ STATEMENT: what the system guarantees
5
+ RATIONALE: why this matters
6
+ VERIFICATION: how to prove or test this
7
+ FAILURE_MODE: what happens if violated
8
+ STATUS: verified / assumed / unverified
9
+ RISK_IF_ASSUMED: [fill if status is assumed]
@@ -0,0 +1,37 @@
1
+ # Investigation Template — Technical Blocker
2
+
3
+ ## INV-XXX: [title]
4
+ DATE:
5
+ STATUS: open / resolved
6
+ TRIGGERED_BY: [what broke — bug, benchmark, unexpected limitation]
7
+
8
+ ## Broken Assumption
9
+ ASSUMPTION_IN: [ADR-N]
10
+ ASSUMPTION_WAS: [what we believed]
11
+ REALITY: [what we discovered]
12
+
13
+ ## Impact
14
+ INVARIANTS_AT_RISK: [list]
15
+ SPECS_AFFECTED: [list]
16
+
17
+ ## Options
18
+ ### Option A: [name]
19
+ Description. Cost. Technical debt introduced (if any).
20
+
21
+ ### Option B: [name]
22
+ Description. Cost. Technical debt introduced (if any).
23
+
24
+ ### Option C: [name]
25
+ Description. Cost. Technical debt introduced (if any).
26
+
27
+ ## Decision
28
+ CHOSEN: [option]
29
+ RATIONALE: [why]
30
+ DECIDED_BY: developer
31
+ DATE_DECIDED:
32
+
33
+ ## Post-Decision Actions
34
+ - [ ] Update affected ADR or create new one
35
+ - [ ] Update invariants.md if changed
36
+ - [ ] Update affected specs
37
+ - [ ] Document any technical debt in debt.md
@@ -0,0 +1,36 @@
1
+ # RFC Template — Request for Change
2
+
3
+ ## RFC-XXX: [title]
4
+ DATE:
5
+ STATUS: open / accepted / rejected / deferred
6
+ TRIGGERED_BY: [what new requirement or information caused this]
7
+
8
+ ## Affected Invariants
9
+ [List invariants from invariants.md that this touches]
10
+
11
+ ## Affected Specs
12
+ [List specs from .specify/ that need revision]
13
+
14
+ ## Change Cost
15
+ SPECS_TO_REVISE: N
16
+ INVARIANTS_TO_CHANGE: M
17
+ ESTIMATED_EFFORT: [rough estimate]
18
+
19
+ ## Options
20
+ ### Option A: [name]
21
+ Description, pros, cons
22
+
23
+ ### Option B: [name]
24
+ Description, pros, cons
25
+
26
+ ## Decision
27
+ CHOSEN: [option]
28
+ RATIONALE: [why]
29
+ DECIDED_BY: developer
30
+ DATE_DECIDED:
31
+
32
+ ## Post-Decision Actions
33
+ - [ ] Update invariants.md
34
+ - [ ] Regenerate constitution.md
35
+ - [ ] Mark affected specs as NEEDS_REVISION
36
+ - [ ] Resume SpecKit
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: devkit-init
3
+ description: Initialize DevKit in any project. Use when developer wants to start using DevKit methodology — whether starting fresh, adding to an existing project with code, or upgrading from spec-kit alone. Triggers on phrases like "init devkit", "setup devkit", "start devkit", "add devkit to project", "initialize devkit".
4
+ license: MIT
5
+ metadata:
6
+ author: devkit
7
+ version: "1.0"
8
+ ---
9
+
10
+ # DevKit Init
11
+
12
+ Initialize DevKit for any project state. Detect what exists, choose the right mode, set up what's needed.
13
+
14
+ ## Step 1: Detect Project State
15
+
16
+ Check what exists in the current directory:
17
+
18
+ ```
19
+ Check for:
20
+ .devkit/ → already initialized
21
+ .specify/ → spec-kit exists, no DevKit
22
+ source code files → brownfield (code without DevKit)
23
+ empty directory → greenfield
24
+ ```
25
+
26
+ Based on findings, choose mode:
27
+
28
+ | State | Mode |
29
+ |-------|------|
30
+ | .devkit/ exists | Already initialized → show status |
31
+ | .specify/ only | Upgrade mode → wrap spec-kit with DevKit |
32
+ | Code, no .devkit/ | Brownfield mode → reconstruct from code |
33
+ | Empty / no code | Greenfield mode → start fresh |
34
+
35
+ Read the mode guide:
36
+ - Greenfield: [greenfield.md](references/greenfield.md)
37
+ - Brownfield: [brownfield.md](references/brownfield.md)
38
+ - Upgrade from spec-kit: [upgrade.md](references/upgrade.md)
39
+
40
+ ## Step 2: Create .devkit/ Structure
41
+
42
+ After determining mode, create the directory structure:
43
+
44
+ ```
45
+ .devkit/
46
+ research/ ← ResearchKit artifacts
47
+ product/ ← ProductKit artifacts
48
+ arch/
49
+ decisions/ ← ADR, RFC, Investigation files
50
+ qa/
51
+ escalations/ ← QA escalation history
52
+ ```
53
+
54
+ ## Step 3: Install spec-kit if not present
55
+
56
+ Check if `specify` CLI is available:
57
+
58
+ ```bash
59
+ specify --version
60
+ ```
61
+
62
+ If not found, output instructions:
63
+ ```
64
+ spec-kit not found. Install with:
65
+ uv tool install specify-cli --from git+https://github.com/github/spec-kit.git
66
+
67
+ Then run: specify init . --ai claude
68
+ ```
69
+
70
+ If found but `.specify/` doesn't exist:
71
+ ```bash
72
+ specify init . --ai claude
73
+ ```
74
+
75
+ ## Step 4: Confirm and Show Next Step
76
+
77
+ After init, tell developer what to do next based on mode:
78
+
79
+ Greenfield:
80
+ ```
81
+ DevKit initialized.
82
+ Start with: /research-kit
83
+ Describe your idea and we'll explore feasibility together.
84
+ ```
85
+
86
+ Brownfield:
87
+ ```
88
+ DevKit initialized in brownfield mode.
89
+ Reconstructed N invariants (review required).
90
+ Next: review .devkit/arch/invariants.md and confirm or correct.
91
+ Then: /arch-kit to fill gaps.
92
+ ```
93
+
94
+ Upgrade:
95
+ ```
96
+ DevKit initialized over existing spec-kit project.
97
+ Reconstructed constitution into ArchKit artifacts.
98
+ Next: review .devkit/arch/invariants.md
99
+ ```
@@ -0,0 +1,147 @@
1
+ # Brownfield Mode
2
+
3
+ Code exists. No .devkit/. May or may not have .specify/.
4
+
5
+ ## Phase 1: Project Scan
6
+
7
+ Read the codebase to understand what exists:
8
+
9
+ ```
10
+ Scan for:
11
+ - Main language and framework
12
+ - Entry points (main files, index, app)
13
+ - Database / storage patterns
14
+ - External services and integrations
15
+ - Test files (understand what's already tested)
16
+ - README or docs (understand stated intent)
17
+ - Package files (dependencies reveal architecture)
18
+ ```
19
+
20
+ Summarize findings before proceeding:
21
+ ```
22
+ Found: [framework], [database], [key integrations]
23
+ Size: ~N files, ~M lines
24
+ Tests: yes/no, coverage unknown
25
+ Docs: yes/no
26
+ ```
27
+
28
+ ## Phase 2: Invariant Extraction
29
+
30
+ Read source code deeply. Look for patterns that reveal implicit invariants:
31
+
32
+ **Signals of technical invariants:**
33
+ - Transactions wrapping multiple operations → atomicity invariant
34
+ - Locks, mutexes, SELECT FOR UPDATE → concurrency invariant
35
+ - Retry logic → reliability invariant
36
+ - Auth checks on every endpoint → security invariant
37
+ - Validation before DB writes → data integrity invariant
38
+
39
+ **Signals of broken invariants:**
40
+ - TODO/FIXME/HACK comments
41
+ - Exception swallowed silently
42
+ - Missing error handling on critical paths
43
+ - Race conditions (no locking where needed)
44
+
45
+ For each extracted invariant, create entry with status `inferred`:
46
+
47
+ ```markdown
48
+ ## I1: [name]
49
+ STATEMENT: what the system appears to guarantee
50
+ STATUS: inferred
51
+ CONFIDENCE: high / medium / low
52
+ SOURCE: code-analysis
53
+ EVIDENCE: [file:line that shows this]
54
+ NEEDS_REVIEW: true
55
+ ```
56
+
57
+ ## Phase 3: Decision Archaeology
58
+
59
+ Look for evidence of past architectural decisions:
60
+
61
+ **Where to look:**
62
+ - Git history and commit messages
63
+ - PR descriptions (if accessible)
64
+ - Comments explaining "why" not "what"
65
+ - Unusual patterns that suggest a workaround
66
+ - Dependencies that seem overengineered for the task
67
+
68
+ For each discovered decision:
69
+
70
+ ```markdown
71
+ ## ADR-XXX: [inferred decision name]
72
+ STATUS: inferred
73
+ CONFIDENCE: high / medium / low
74
+ EVIDENCE: [what in code suggests this]
75
+ UNKNOWN: [what context is lost]
76
+ NEEDS_REVIEW: true
77
+ ```
78
+
79
+ ## Phase 4: Gap Analysis
80
+
81
+ What can't be reconstructed from code alone?
82
+
83
+ ```markdown
84
+ # Gaps
85
+
86
+ ## UNKNOWN: [topic]
87
+ QUESTION: what we can't determine from code
88
+ WHY_MATTERS: impact on future development
89
+ HOW_TO_RESOLVE: ask developer / check git history / accept unknown
90
+ ```
91
+
92
+ Present gaps to developer and ask them to fill what they remember.
93
+
94
+ ## Phase 5: Produce Artifacts
95
+
96
+ Save to `.devkit/arch/`:
97
+ - `invariants.md` — all inferred invariants (status: inferred, needs_review: true)
98
+ - `decisions/ADR-*.md` — all inferred decisions
99
+ - `impact.md` — dependency map extracted from imports/calls
100
+
101
+ ## Status File
102
+
103
+ Create `.devkit/STATUS.md`:
104
+
105
+ ```markdown
106
+ # DevKit Status
107
+
108
+ MODE: brownfield
109
+ INITIALIZED: [date]
110
+ CURRENT_PHASE: arch-review
111
+
112
+ ## Reconstruction Summary
113
+ INVARIANTS_INFERRED: N
114
+ DECISIONS_INFERRED: M
115
+ GAPS: K (see arch/gaps.md)
116
+
117
+ ## Required Actions Before Development
118
+ - [ ] Review and confirm invariants.md
119
+ - [ ] Fill gaps in arch/gaps.md
120
+ - [ ] Run /arch-kit to verify and fill missing decisions
121
+
122
+ ## Phase Status
123
+ - [~] ResearchKit (skipped — existing project)
124
+ - [~] ProductKit (partially reconstructed)
125
+ - [ ] ArchKit (review required)
126
+ - [ ] SpecKit
127
+ - [ ] QAKit
128
+ ```
129
+
130
+ ## Message to Developer
131
+
132
+ ```
133
+ DevKit initialized in brownfield mode.
134
+
135
+ Reconstructed from your codebase:
136
+ Invariants: N (all marked as 'inferred', need your review)
137
+ Decisions: M (inferred from code patterns)
138
+ Gaps: K unknowns that couldn't be reconstructed
139
+
140
+ Next steps:
141
+ 1. Review .devkit/arch/invariants.md — confirm or correct each one
142
+ 2. Check .devkit/arch/gaps.md — fill what you remember
143
+ 3. Run /arch-kit to verify architecture and fill remaining gaps
144
+
145
+ Important: 'inferred' invariants are AI's best guess from code.
146
+ They may be wrong. Please review before trusting them.
147
+ ```