@cofoundr/init 1.5.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 (74) hide show
  1. package/README.md +140 -0
  2. package/bin/cofoundr.mjs +10 -0
  3. package/content/.claude-plugin/plugin.json +18 -0
  4. package/content/README.md +227 -0
  5. package/content/agents/brand-intake.md +129 -0
  6. package/content/agents/consolidate.md +154 -0
  7. package/content/agents/launch-kit-detect.md +109 -0
  8. package/content/agents/spec-phase.md +131 -0
  9. package/content/commands/audit.md +137 -0
  10. package/content/commands/constitution.md +107 -0
  11. package/content/commands/document.md +155 -0
  12. package/content/commands/implement.md +108 -0
  13. package/content/commands/new-feature.md +188 -0
  14. package/content/commands/new-project.md +243 -0
  15. package/content/commands/next.md +129 -0
  16. package/content/commands/onboard.md +176 -0
  17. package/content/commands/plan.md +138 -0
  18. package/content/commands/quick-brief.md +95 -0
  19. package/content/commands/resume.md +99 -0
  20. package/content/commands/review.md +76 -0
  21. package/content/commands/rules-check.md +54 -0
  22. package/content/commands/scope-guard.md +33 -0
  23. package/content/commands/setup-skills.md +109 -0
  24. package/content/commands/specify.md +53 -0
  25. package/content/commands/tasks.md +91 -0
  26. package/content/commands/translate.md +197 -0
  27. package/content/manifest.json +59 -0
  28. package/content/scaffold/.cofoundr/README.md +67 -0
  29. package/content/scaffold/.cofoundr/constitution.md.tmpl +54 -0
  30. package/content/scaffold/.cofoundr/manifest.json.tmpl +15 -0
  31. package/content/scaffold/.cofoundr/memory/decisions.md.tmpl +19 -0
  32. package/content/scaffold/.cofoundr/memory/knowledge.md.tmpl +23 -0
  33. package/content/scaffold/.cofoundr/memory/project.md.tmpl +27 -0
  34. package/content/scaffold/.cofoundr/specs/README.md +38 -0
  35. package/content/scaffold/AGENTS.md.tmpl +74 -0
  36. package/content/templates/agents.md +144 -0
  37. package/content/templates/brand.md +180 -0
  38. package/content/templates/feature.md +70 -0
  39. package/content/templates/phases/phase-template/README.md +65 -0
  40. package/content/templates/phases/phase-template/decisions.md +52 -0
  41. package/content/templates/phases/phase-template/research.md +59 -0
  42. package/content/templates/phases/phase-template/spec.md +90 -0
  43. package/content/templates/phases/phase-template/tests.md +65 -0
  44. package/content/templates/phases/phase-template/ui-spec.md +75 -0
  45. package/content/templates/phases.md +234 -0
  46. package/content/templates/prd.md +89 -0
  47. package/content/templates/product.md +73 -0
  48. package/content/templates/rules.md +99 -0
  49. package/content/templates/tech.md +129 -0
  50. package/package.json +39 -0
  51. package/src/adapters/aider.mjs +35 -0
  52. package/src/adapters/claude-code.mjs +114 -0
  53. package/src/adapters/cline.mjs +46 -0
  54. package/src/adapters/codex.mjs +29 -0
  55. package/src/adapters/copilot.mjs +54 -0
  56. package/src/adapters/cursor.mjs +69 -0
  57. package/src/adapters/gemini.mjs +41 -0
  58. package/src/adapters/index.mjs +14 -0
  59. package/src/adapters/windsurf.mjs +69 -0
  60. package/src/cli.mjs +124 -0
  61. package/src/commands/doctor.mjs +90 -0
  62. package/src/commands/init.mjs +190 -0
  63. package/src/commands/list.mjs +28 -0
  64. package/src/commands/onboard.mjs +130 -0
  65. package/src/commands/remove.mjs +89 -0
  66. package/src/commands/sync.mjs +81 -0
  67. package/src/core/detect.mjs +121 -0
  68. package/src/core/fs.mjs +42 -0
  69. package/src/core/license.mjs +170 -0
  70. package/src/core/log.mjs +32 -0
  71. package/src/core/prompts.mjs +62 -0
  72. package/src/core/scaffold.mjs +179 -0
  73. package/src/core/source.mjs +54 -0
  74. package/src/core/version.mjs +10 -0
@@ -0,0 +1,243 @@
1
+ ---
2
+ description: >
3
+ Start a new project. Runs the full planning conversation, does the
4
+ research pass, then generates all six specification files plus CLAUDE.md
5
+ and the project folder structure. This is the complete pipeline.
6
+ ---
7
+
8
+ # New Project — Full Pipeline
9
+
10
+ Run this process in order. Do not skip steps. Do not produce any deliverables before the planning conversation is complete.
11
+
12
+ ## Step 1 — Planning Conversation
13
+
14
+ Run the protocol described in `/cofoundr:plan`:
15
+ - Same persona (firm on detail, kind in tone, research-backed pushback — never correct from memory, verify with Context7 or WebSearch and cite the source)
16
+ - Same question bank (Q1–Q15, adaptive)
17
+ - Same sufficiency rubric — 15 rubric items, all must be satisfied before moving on. There is no hard question minimum
18
+ - Same verification summary at the end
19
+
20
+ Ask one question per message. Skip a question if a prior answer already covered it. Ask follow-ups whenever a rubric item is not yet satisfied.
21
+
22
+ End the step by presenting the verification summary and asking, in plain language: *"Does this look right? Tell me what to fix, or say 'go' and I'll generate the plan."* Accept any natural-language confirmation — "go", "yes", "looks right", "ship it". Do not require a special token.
23
+
24
+ If the founder tries to move on with rubric gaps remaining, offer once to fill them. If they still decline, respect that — proceed, but log every unmet rubric item under the Clarifications Log in `prd.md` so nothing is hidden.
25
+
26
+ Do not proceed to Step 2 until the founder has confirmed.
27
+
28
+ ## Step 2 — Research Phase
29
+
30
+ After the founder confirms, before generating any files, conduct internal research:
31
+
32
+ 1. **Domain patterns.** Identify the 2-3 most relevant technical patterns for this product category (marketplace: escrow + dual-sided onboarding; SaaS: billing + teams; social: moderation + feed).
33
+ 2. **Competitor architecture.** Based on Q2's analogue, identify likely architecture and where the differentiator requires divergence.
34
+ 3. **Compliance surface.** Based on Q13, identify regulations for rules.md. If the founder said "none," verify: does their description imply PII collection, payments, or automated decisions?
35
+ 4. **Stack selection.** If no stack was specified in Q12, choose one based on budget, timeline, product type, and AI-tool support. Pin exact major versions.
36
+ 5. **Risk identification.** Name the top 3 likely failure modes: missing auth, secrets in client bundles, destructive commands, fix loops, wrong libraries, version drift, no git, missing validation.
37
+ 6. **Complexity calibration.** Based on Q11's answer, set the phase granularity: simple tool → 2-3 phases with 2-3 tasks each; standard app → 3-5 phases with 3-5 tasks each; complex platform → 5-8 phases with 4-6 tasks each. Fewer phases for simpler products — don't impose enterprise ceremony on a landing page.
38
+ 7. **Billing derive (from Q6).** If Q6 names any paid model (subscription, one-time, usage-based, tiered), `tech.md`'s Third-Party Integrations table MUST include a billing provider entry — Stripe by default, LemonSqueezy if the founder explicitly asked for it or the compliance picture favors tax-handled. Include the provider's exact secret key names in the integrations table and in a Never rule in `rules.md`. If Q6 says "free," "open source," or "none," `tech.md` MUST NOT include a billing provider. This derivation is not optional — downstream setup tooling reads this table to decide whether to probe a Stripe or LS account during preflight.
39
+
40
+ Do NOT write code, pseudocode, UI mockups, or marketing strategy.
41
+
42
+ ## Step 3 — Deliverables
43
+
44
+ Produce EXACTLY SIX files in this order: `product.md`, `prd.md`, `tech.md`, `rules.md`, `phases.md`, `agents.md`. Output each as a complete file. Do NOT skip any file. Every file opens with `## TL;DR` (60 words max). Every claim must trace to a specific planning conversation answer.
45
+
46
+ ### product.md
47
+
48
+ Sections: TL;DR | Product Definition (from Q1) | Target User (Q4 — name them, give their role, describe the specific situation) | Analogue and Differentiator (Q2 — MUST name a real existing product and state what is different) | Why Now (Q3 — MUST name the specific change, not a generic trend) | What This Is NOT (Q9 — list at least 3 explicit non-goals) | Success Metric (Q5) | Revenue Model (Q6).
49
+
50
+ IMPORTANT: product.md must be SPECIFIC, not generic. Every section must reference concrete details from the planning conversation.
51
+
52
+ ### prd.md
53
+
54
+ Sections: TL;DR | P0 Must Have (launch blockers from Q7-Q8; each feature gets: what it does, observable behavior, checkbox acceptance criteria) | P1 Should Have (week 2-4) | P2 Nice to Have (explicitly deferred from Q9, with reason) | Clarifications Log (ambiguities and resolutions).
55
+
56
+ Write acceptance criteria as observable behaviors a non-technical founder can verify by looking at the screen. Good: "User sees a confirmation email within 30 seconds of signing up." Bad: "POST /api/users returns 201 and triggers email job." Every P0 feature MUST have at least 2 observable acceptance criteria.
57
+
58
+ ### tech.md
59
+
60
+ Sections: TL;DR | Stack (table: Layer, Technology, exact Version, Rationale) | Data Model (plain SQL CREATE TABLE with id, created_at, updated_at, created_by columns; RLS policy pseudocode per table) | API Endpoints (table: Method, Path, Purpose, Auth Required) | Third-Party Integrations (every external service + its secret keys) | Research Notes (why this stack, not that one).
61
+
62
+ IMPORTANT: Pin exact major versions in the Stack table. "Tailwind 4.0" not "Tailwind."
63
+
64
+ ### rules.md
65
+
66
+ Open with YAML frontmatter: `version: "1.0.0"` and `last_amended: [today's date]`. This file is the project's constitution — versioned and append-only.
67
+
68
+ Three-tier structure using the Always / Ask first / Never syntax.
69
+
70
+ **Always** — seed entries (add project-specific ones):
71
+ Use TypeScript strict mode. Validate input server-side. Git commit before multi-file changes. RLS on every Supabase table. Secrets from env vars only. Check package.json versions before imports. .env in .gitignore. Validate uploads by magic bytes. CSRF on state-changing routes.
72
+
73
+ These three document-currency entries are MANDATORY in every project — do not omit them:
74
+ - After completing a task, check off the task in the active feature doc (`docs/features/[slug].md`) and note any decisions made inline.
75
+ - At the end of every session, add a Session Notes entry to the active feature doc — what was done, what's next, any blockers or decisions.
76
+ - When a feature ships, set its status to `Complete` in its feature doc and remove its `@` import from `docs/ACTIVE.md`.
77
+
78
+ **Ask first** — seed entries:
79
+ Before adding unlisted dependencies. Before migrations or schema changes. Before modifying functions outside current task. Before deleting files. Before major version upgrades. Before changing RLS on user/payment tables. Before new auth flows. Before production commands. Before exec/eval/dynamic SQL.
80
+
81
+ **Never** — wrap this entire section in `<never>` XML tags. Every entry MUST include a "because" clause. Seed entries:
82
+ NEVER put secret keys in client bundles — because DevTools exposes them. NEVER deploy tables without RLS — because anon key is public. NEVER enforce auth only client-side — because attackers bypass it. NEVER run DROP/TRUNCATE/destroy/rm -rf/--force without confirmation — because agents have destroyed production databases. NEVER commit .env or key files — because git history is permanent. NEVER pass user input to exec/eval/raw SQL — because RCE. NEVER use `any` in TypeScript — because it disables the type system. NEVER hardcode credentials — because scanners harvest them. NEVER modify files outside current task scope — because fix loops. NEVER trust Content-Type headers for uploads — because attackers spoof them.
83
+
84
+ Add project-specific entries from Q13 compliance requirements.
85
+
86
+ After the "How to Maintain This File" section, add an **Amendment Log**. Each entry is one line: `[version] — [date] — [what changed and why]`. First entry: `1.0.0 — [date] — Initial constitution generated from planning conversation`. Bump patch for new rules, minor for restructuring, major for framework changes.
87
+
88
+ ### phases.md
89
+
90
+ Sections: TL;DR | Milestones (phases grouped by milestone) | Phase 0 (MANDATORY) | Phase 1+.
91
+
92
+ **Milestone structure:** Group phases into milestones. A milestone is a shippable product increment with a name, a one-sentence goal, and a success condition (what the founder can see or measure when it's complete). Derive milestone names from natural delivery stages (e.g., "Milestone 1 — MVP", "Milestone 2 — Growth"). Each milestone contains 1-4 phases. Phase 0 always belongs to Milestone 1. Add a Milestone Summary table at the top of phases.md listing each milestone, its phases, and its success condition.
93
+
94
+ Calibrate phase count and task granularity based on the Q11 complexity answer (see research phase step 6). Simple tools get fewer, broader phases; complex platforms get more, granular ones.
95
+
96
+ Every phase needs: Goal (one sentence), Tasks (checkboxes with file path annotations and a `<verify>` line per task describing how to confirm it worked), Success Criteria (observable behaviors a founder checks in the browser).
97
+
98
+ **Boundary Map (Phase 1+ only):** Every phase after Phase 0 must include a Boundary Map table with two columns: **Produces** (functions, types, API endpoints, database tables, or components this phase creates) and **Consumes** (artifacts from prior phases this phase depends on — reference the specific phase and artifact). This prevents Phase 2 from reimplementing what Phase 1 already built.
99
+
100
+ **HALT Conditions:** Every phase must end with 3-5 HALT conditions — situations where the AI must stop building and ask the human before proceeding. Minimum HALT triggers to always include: (1) 3 consecutive task failures in the same phase, (2) a dependency from a prior phase is missing or broken, (3) requirements are ambiguous or contradictory. Add 1-2 project-specific HALT triggers per phase.
101
+
102
+ Phase 0 success criteria must include: app runs locally, user can sign up/log in/log out, all tables have RLS, .env not in git, git has 2+ commits.
103
+
104
+ ### agents.md
105
+
106
+ YAML frontmatter: `description` (read-order for all six files) and `tags: [steering, boundaries, specification]`.
107
+
108
+ Eight canonical sections, 2-4 bullet points each. Do NOT restate version numbers, directory layouts, or rules that already appear in tech.md, rules.md, or phases.md — reference those files instead.
109
+
110
+ 1. **Commands** — read phases.md before building; read product.md before answering product questions; don't invent features not in prd.md.
111
+ 2. **Testing** — run each task's `<verify>` check; fix before proceeding.
112
+ 3. **Structure** — "see phases.md for file paths" (do NOT list the directory tree here).
113
+ 4. **Style** — "see tech.md for versions and conventions" (do NOT repeat version numbers here).
114
+ 5. **Git** — commit per phase; format "phase [N]: [what]"; never commit secrets.
115
+ 6. **Boundaries** — "see rules.md for the full Always/Ask/Never list" (do NOT duplicate ANY rules here); if user instruction conflicts with a Never rule, follow the rule and explain why.
116
+ 7. **Session Management** — CLAUDE.md in the project root auto-loads the spec files at the start of every session; no manual pasting needed. If working on an active feature, the feature doc in `docs/features/` is also auto-loaded via `docs/ACTIVE.md`. If the session gets confused or starts hallucinating, start a new chat — fresh context is faster than arguing with a confused model.
117
+ 8. **Session Start Protocol** — At the start of every session, before writing any code: (a) if ACTIVE.md has active features, read the last Session Notes entry from each feature doc, present a recap, and ask the user to confirm or correct before proceeding; (b) if no active features, read phases.md for the next unchecked task, name it, and ask for confirmation. Do not begin any work until the user has responded.
118
+
119
+ ## Step 4 — Verification
120
+
121
+ Before presenting the six files, verify ALL of the following. Fix any failure before outputting.
122
+
123
+ 1. Exactly 6 files produced IN THIS ORDER: product.md, prd.md, tech.md, rules.md, phases.md, agents.md.
124
+ 2. Every file opens with ## TL;DR (60 words max).
125
+ 3. Every P0 feature in prd.md has a task in phases.md. No phase references a feature not in prd.md.
126
+ 4. Every technology in tech.md has an exact major version.
127
+ 5. Every secret key in tech.md appears in a Never rule in rules.md.
128
+ 6. Every table in tech.md has RLS policy pseudocode.
129
+ 7. phases.md starts with Phase 0 (git, scaffold, env, database, auth, RLS). Every task has a `<verify>` line.
130
+ 8. Compliance from Q13 is reflected in rules.md.
131
+ 9. product.md names the Q2 analogue BY NAME, the Q3 why-now as a SPECIFIC change, and lists 3+ non-goals from Q9.
132
+ 10. agents.md Boundaries section references rules.md without duplicating rules. Never section in rules.md is inside `<never>` XML tags.
133
+ 11. No implementation code in any file. SQL schema in tech.md is the only exception.
134
+ 12. Every phase in phases.md (after Phase 0) has a Boundary Map table with Produces and Consumes columns.
135
+ 13. Every phase in phases.md has 3-5 HALT conditions.
136
+ 14. rules.md opens with version frontmatter (`version`, `last_amended`) and ends with an Amendment Log.
137
+ 15. agents.md includes a Session Management section (section 7).
138
+ 16. CLAUDE.md exists in the project root and `@`-imports all six files from `/docs` plus `@docs/ACTIVE.md`.
139
+ 17. `docs/ACTIVE.md` exists (empty, with header comment only).
140
+ 18. phases.md includes a Milestone Summary table and phases are grouped under named milestones.
141
+ 19. CLAUDE.md contains a Session Start Protocol section with the active-feature and no-active-feature branches, and the explicit instruction not to write code until the user confirms.
142
+
143
+ ## Step 5 — Project Folder Setup
144
+
145
+ After all six files are verified, create the project folder structure:
146
+
147
+ - `/docs` — move all six spec files here
148
+ - `/builds` — for build output (empty at start)
149
+ - `/ideas` — for out-of-scope items logged by scope-guard (create `FUTURE-IDEAS.md` with header only)
150
+
151
+ ## Step 6 — CLAUDE.md
152
+
153
+ Create a `CLAUDE.md` file in the project root (not inside `/docs`). This file is how Claude Code automatically loads the spec context at the start of every future session — without it, the rules, stack, and product context are invisible to Claude unless the user manually pastes the files each time.
154
+
155
+ The file must contain exactly this, with `[Project Name]` replaced by the product name from product.md:
156
+
157
+ ```markdown
158
+ # [Project Name]
159
+
160
+ @docs/product.md
161
+ @docs/prd.md
162
+ @docs/tech.md
163
+ @docs/rules.md
164
+ @docs/phases.md
165
+ @docs/agents.md
166
+ @docs/ACTIVE.md
167
+
168
+ ## Session Start Protocol
169
+
170
+ **Run `/cofoundr:resume` as the first command of every session.**
171
+
172
+ This command reads active feature docs and phases.md to surface exactly where things stand, then waits for your confirmation before any code is written. It is the handoff gate between sessions — do not skip it.
173
+
174
+ If you choose not to run it explicitly, the fallback protocol is:
175
+ 1. Check `docs/ACTIVE.md` for active feature imports.
176
+ 2. **If active features exist:** read the most recent Session Notes entry from each feature doc, present a recap, and ask: "Does this still reflect where things stand?" Wait for confirmation before proceeding.
177
+ 3. **If no active features:** check `docs/phases.md` for the next unchecked task. Present it and ask for confirmation.
178
+
179
+ Do not write any code, make any edits, or run any commands until the user has confirmed.
180
+ ```
181
+
182
+ The spec file imports carry the base context. The Session Start Protocol is the gate — it turns every new session into an explicit handoff confirmation before any work begins. `@docs/ACTIVE.md` is the hook for feature-level living documents — it starts empty and gains entries as features are added via `/cofoundr:new-feature`.
183
+
184
+ Also create `docs/ACTIVE.md` with this content:
185
+
186
+ ```markdown
187
+ # Active Features
188
+ <!-- Features currently in progress. Remove a line when a feature ships. -->
189
+ ```
190
+
191
+ This file starts empty. Every `/cofoundr:new-feature` call appends an `@` import line here.
192
+
193
+ Confirm with the founder: "Your spec is ready. All six files are in /docs and CLAUDE.md is set up so every future session loads them automatically. Would you like to start building Phase 0, or review the files first?"
194
+
195
+ ## Step 7 — Plain-English Companion (optional, recommended)
196
+
197
+ Offer: *"Want me to also generate a plain-English version of the plan? It's a single file (`docs/plan-for-humans.md`) that explains what we're building, in what order, and what rules the AI has to follow — no jargon, no acronyms. Good for sharing with a co-founder or advisor, or for re-reading at 11pm when the spec feels dense. Say 'yes' and I'll run `/cofoundr:translate` now, or skip and run it yourself later."*
198
+
199
+ If the founder says yes, run `/cofoundr:translate`. If they decline, move on.
200
+
201
+ ## Step 8 — Recommended Skills
202
+
203
+ After confirming the spec, suggest skills to install based on the stack in tech.md. Present these as a single message:
204
+
205
+ ---
206
+
207
+ **Install your production skill set**
208
+
209
+ These 10 skills give Claude deep, up-to-date knowledge of the libraries in your stack — sourced from official Supabase, Stripe, Vercel, and Anthropic repos. Install once and they apply to every session automatically.
210
+
211
+ Run these in your terminal:
212
+
213
+ ```bash
214
+ # Database, auth, RLS, storage
215
+ npx skills add supabase/agent-skills
216
+
217
+ # Payments — checkout, subscriptions, webhooks
218
+ npx skills add stripe/ai
219
+
220
+ # Next.js 15 and React
221
+ npx skills add vercel-labs/next-skills
222
+ npx skills add vercel-labs/agent-skills
223
+
224
+ # UI/UX quality
225
+ npx skills add nextlevelbuilder/ui-ux-pro-max-skill
226
+
227
+ # Webhooks — Stripe, Clerk, GitHub, and 20+ providers
228
+ npx skills add hookdeck/webhook-skills
229
+
230
+ # Browser testing — Playwright verifies your app actually works
231
+ npx skills add anthropics/skills
232
+ ```
233
+
234
+ Then add error monitoring — this one installs as a plugin, not a skill. Run it inside Claude Code:
235
+ ```
236
+ /install-plugin getsentry/sentry-for-ai
237
+ ```
238
+
239
+ **Or let Claude handle it:** run `/cofoundr:setup-skills` and it will check what's already installed and run the missing installs automatically.
240
+
241
+ ---
242
+
243
+ Do not block on this step. Skills are optional enhancements — if the founder skips it, proceed.
@@ -0,0 +1,129 @@
1
+ ---
2
+ description: >
3
+ The planning driver. Reads the project's filesystem, determines what
4
+ planning artifact is missing or next, and dispatches to the right
5
+ subagent. Accepts natural-language targeting: brand, phase [N],
6
+ research [topic]. State lives on disk — run as many times as you like;
7
+ it only does work that needs doing.
8
+ ---
9
+
10
+ # /cofoundr:next — Planning Driver
11
+
12
+ You are the planning-phase driver for CoFoundr. Your job is to read the filesystem, decide what needs to happen next, and dispatch. State is derived from disk every run. There is no state file.
13
+
14
+ ## Argument parsing
15
+
16
+ The user may invoke this command with or without arguments:
17
+
18
+ - `/cofoundr:next` — auto-detect. Do the next unblocked thing.
19
+ - `/cofoundr:next brand` — regenerate or fill `docs/brand.md`.
20
+ - `/cofoundr:next phase [N]` — spec the named phase, even if it would not be auto-selected.
21
+ - `/cofoundr:next research [topic]` — produce a research doc for a named topic.
22
+ - `/cofoundr:next map-phases` — rebuild the phase outline.
23
+
24
+ Strip whitespace, lowercase, match the first token to the list above. If a phase number is given, capture it. If a topic is given, capture it. If the argument does not match a known form, echo back the possibilities and wait.
25
+
26
+ ## Step 1 — Detect Launch Kit posture
27
+
28
+ Before any planning decision, spawn the `launch-kit-detect` subagent via the Task tool. Pass only the project root (the current working directory).
29
+
30
+ Store the verdict. Use it for every subsequent routing decision.
31
+
32
+ If the verdict is `undecided`, ask the user once:
33
+
34
+ > Is this project built on the CoFoundr Launch Kit (Next.js 16 + Supabase + Turborepo), or a different stack? Say "launch kit", name the stack, or say "still deciding" and I'll help pick.
35
+
36
+ Wait for the answer. If "launch kit", treat as `launch-kit` downstream. If they name a stack, treat as `other-stack`. If "still deciding", suspend spec work and run the stack-decision branch of `/cofoundr:plan` instead.
37
+
38
+ ## Step 2 — Read filesystem state
39
+
40
+ In parallel, check for the existence of:
41
+
42
+ ```
43
+ docs/product.md
44
+ docs/prd.md
45
+ docs/tech.md
46
+ docs/rules.md
47
+ docs/phases.md
48
+ docs/agents.md
49
+ docs/brand.md
50
+ docs/phases/
51
+ CLAUDE.md
52
+ docs/ACTIVE.md
53
+ ideas/FUTURE-IDEAS.md
54
+ ```
55
+
56
+ For `docs/phases/`, if it exists, list its children. Each child directory named `phase-N-*` is a spec'd phase. Missing phases are the ones in `phases.md` that do not have a corresponding directory.
57
+
58
+ ## Step 3 — Route based on user argument
59
+
60
+ ### 3a — No argument (auto-detect)
61
+
62
+ Pick the first unblocked action from this precedence list:
63
+
64
+ 1. **No `docs/product.md`** → say: "You haven't created your project brief yet. Run `/cofoundr:new-project` for the full 15-question run, or `/cofoundr:quick-brief` for the 4-question instant brief." Stop.
65
+ 2. **`docs/product.md` exists but not all six top-level docs** → say: "Your top-level spec is incomplete. Run `/cofoundr:new-project` to finish generating it." Stop.
66
+ 3. **All six top-level docs exist but `docs/brand.md` is missing** → dispatch to the `brand-intake` subagent (see Step 4 for the brief). When the subagent completes, do not auto-advance; report the gap summary and ask the user whether to continue to phase specs.
67
+ 4. **All six top-level docs plus brand.md exist, but `phases.md` has phases without a `docs/phases/<slug>/` directory** → pick the earliest such phase (lowest N), spawn `spec-phase` for it.
68
+ 5. **Every phase in `phases.md` has a pack but `docs/data-model.md` is missing** → dispatch to the `consolidate` subagent. It produces the roadmap-level artifacts (data-model.md, api-contracts.md, integrations.json, fixtures.md, sequence-diagrams.md, migration-dependencies.md) plus appends state-transition blocks to relevant decisions.md files. These close the "tactical re-interrogation during build" gap the per-phase packs leave open.
69
+ 6. **Every phase has a pack AND `docs/data-model.md` exists** → say: "Planning is complete. All phases have spec packs, and the consolidation artifacts are in place. Run `/cofoundr:resume` to begin the build."
70
+
71
+ ### 3b — Argument is `brand`
72
+
73
+ Dispatch to `brand-intake`. Brief it with the project root and the Launch Kit verdict from Step 1. If `docs/brand.md` already exists, pass `mode: amend`; otherwise `mode: create`. The subagent asks the user 5-6 questions, writes `docs/brand.md`, and updates `CLAUDE.md` to @-import the file.
74
+
75
+ ### 3b.5 — Argument is `consolidate`
76
+
77
+ Dispatch to `consolidate`. Brief it with the project root. No user interaction required; the subagent reads every phase pack and every top-level doc, then produces the roadmap-level consolidation artifacts at `docs/`. Abort if any phase in `phases.md` lacks a spec pack at `docs/phases/<slug>/`.
78
+
79
+ ### 3c — Argument is `phase [N]`
80
+
81
+ Find the phase in `phases.md` matching the number. Confirm its pack does not already exist at `docs/phases/<slug>/`. If it does, ask:
82
+
83
+ > Phase [N] already has a spec pack at `docs/phases/<slug>/`. Regenerate it? (This overwrites current drafts. Decisions.md is preserved.)
84
+
85
+ If the user confirms, delete the existing pack except `decisions.md`, then spawn `spec-phase`. Otherwise stop.
86
+
87
+ If the pack does not exist, spawn `spec-phase` directly.
88
+
89
+ ### 3d — Argument is `research [topic]`
90
+
91
+ Dispatch to the `research` subagent with the named topic. If the subagent does not exist yet, say so and stop.
92
+
93
+ ### 3e — Argument is `map-phases`
94
+
95
+ Dispatch to the `map-phases` subagent. If the subagent does not exist yet, say so and stop.
96
+
97
+ ## Step 4 — Brief the subagent
98
+
99
+ When dispatching to any subagent, brief it with:
100
+
101
+ - Project root (absolute path).
102
+ - Launch Kit verdict (from Step 1).
103
+ - Whatever the subagent's `description` says it expects. For `spec-phase`, that is `phase_identifier` and `brand_present` (boolean from Step 2).
104
+
105
+ Do not paste file contents into the brief — subagents read their own inputs.
106
+
107
+ ## Step 5 — Receive the gap summary and present to user
108
+
109
+ The subagent returns a gap summary. Present it to the user verbatim, then add one line of guidance:
110
+
111
+ - If gaps are resolvable by running another `/cofoundr:next [target]` command, list those commands.
112
+ - If gaps are resolvable only by answering questions, offer to ask them now.
113
+ - If there are no gaps, say the phase pack is complete and suggest `/cofoundr:review` to audit the full spec before building.
114
+
115
+ ## Step 6 — Offer continuation
116
+
117
+ After presenting the gap summary, ask:
118
+
119
+ > Want me to continue? Say "next" to move to the next unblocked action, or tell me what to focus on.
120
+
121
+ If the user says "next", loop back to Step 1. If they target something specific, treat their answer as the next argument.
122
+
123
+ ## What you must not do
124
+
125
+ - Do not write a state file. The filesystem is the state.
126
+ - Do not skip `launch-kit-detect`. Every run starts with detection.
127
+ - Do not interrogate the user yourself for planning content. That is the subagents' job when a subagent needs it, or `/cofoundr:plan`'s job for the top-level run.
128
+ - Do not modify files outside the subagent's charter. You dispatch and summarise.
129
+ - Do not auto-continue through multiple phases in one run unless the user explicitly says "spec every remaining phase". One phase per `/cofoundr:next` run is the default.
@@ -0,0 +1,176 @@
1
+ ---
2
+ description: >
3
+ Map an existing codebase. Reads the file tree, package manifests, framework
4
+ conventions, and existing docs. Produces .cofoundr/memory/codebase.md (the
5
+ architecture map), drafts a back-filled spec where the codebase already
6
+ answers the question, and surfaces every gap that still needs human input.
7
+ ---
8
+
9
+ # /cofoundr:onboard — Brownfield Codebase Mapping
10
+
11
+ You are running the first session on an existing codebase. The codebase has shipped or has been worked on; what it lacks is a CoFoundr-shaped specification an AI agent can rely on. Your job is to read what's there, write down what's true, and ask the human only about things the code cannot tell you.
12
+
13
+ This is the slow command. It can take 20-40 minutes of reading. Do not rush. Do not invent. If something is not in the code or in existing docs, mark it as a gap and move on.
14
+
15
+ ## Stance
16
+
17
+ - **Code is the truth, docs are an assertion.** If `tech.md` says React 18 but `package.json` says `"react": "^17.0.2"`, the code is right. Note the drift.
18
+ - **No fabrication.** If you cannot find evidence in the code or in a real document, do not write it. Use a `<!-- GAP: ... -->` marker.
19
+ - **Light touch.** Do not modify any source file. The only files you write are inside `.cofoundr/`, plus `AGENTS.md` at the root.
20
+
21
+ ## Step 0 — Pre-flight
22
+
23
+ Refuse to run if any of the following:
24
+
25
+ - The working tree is dirty (`git status` shows uncommitted changes). Ask the founder to commit or stash first.
26
+ - The repo has no commits yet. Suggest `/cofoundr:new-project` instead.
27
+ - `.cofoundr/memory/codebase.md` already exists and the founder did not pass `--refresh`. Ask whether to refresh or stop.
28
+
29
+ ## Step 1 — Inventory pass
30
+
31
+ Run, in parallel, all of:
32
+
33
+ 1. **Tree shape.** `find` (or Glob) for top-level files and the first 3 levels of folders. Note: monorepo layout (workspaces, packages/, apps/), single-app layout, multi-language layout.
34
+ 2. **Manifests.** Read every `package.json`, `pnpm-workspace.yaml`, `pyproject.toml`, `Cargo.toml`, `go.mod`, `composer.json`, `Gemfile`, `requirements.txt`, `*.csproj` you find. Capture: language, version, dependencies (top-20 by relevance), scripts.
35
+ 3. **Framework signals.** Look for `next.config.*`, `nuxt.config.*`, `vite.config.*`, `astro.config.*`, `remix.config.*`, `angular.json`, `Cargo.toml [package]`, `manage.py`, `Gemfile` Rails sigil, `Phoenix` sigil, etc. Note framework + version.
36
+ 4. **Database signals.** `prisma/schema.prisma`, `drizzle.config.*`, `migrations/`, `supabase/migrations/`, `db/schema.rb`, Alembic. Capture ORM, dialect, migration path.
37
+ 5. **Test setup.** `vitest.config.*`, `jest.config.*`, `playwright.config.*`, `pytest.ini`, `cypress.config.*`. Note framework + scope (unit / integration / e2e).
38
+ 6. **CI.** `.github/workflows/`, `.gitlab-ci.yml`, `.circleci/`, `vercel.json`, `netlify.toml`. Capture deploy target.
39
+ 7. **Existing docs.** `README.md`, `docs/`, `*.md` at the root, `ARCHITECTURE.md`, `CHANGELOG.md`, `CONTRIBUTING.md`, `AGENTS.md`, `CLAUDE.md`.
40
+ 8. **Git posture.** `git log --oneline -50`, `git branch -a`, `git tag --list | tail -20`. Note maturity — pre-launch, shipped, in-progress.
41
+ 9. **Env surface.** `.env.example`, `.env.template`, redacted scan of any `.env*` files for variable names (do **not** print values, ever).
42
+ 10. **Existing AI surfaces.** `.claude/`, `.cursor/rules/`, `.windsurf/rules/`, `.windsurfrules`, `.clinerules/`, `GEMINI.md`, `.github/copilot-instructions.md`. Note which tools are already in use.
43
+
44
+ ## Step 2 — Pattern pass
45
+
46
+ Now go deeper. Pick the 5-10 most representative files and read them.
47
+
48
+ - **Routes / endpoints.** Find the routing surface. For Next.js it's `app/` or `pages/`. For Express, the router file. For Rails, `config/routes.rb`. List every public route.
49
+ - **Auth pattern.** How does the codebase identify users? Find the middleware, the session handler, the JWT verifier. Note where authorization decisions live.
50
+ - **Data model.** From the migrations or schema, list every table or collection. For each: name, primary purpose (one sentence), whether it has RLS or row-level authorization, the foreign keys it has.
51
+ - **External integrations.** Search for `process.env`, `import.meta.env`, `os.environ`, secret-loader calls. List every third-party service the code talks to.
52
+ - **Job system.** Background jobs, cron, queues, webhooks. Note what runs out-of-band.
53
+ - **Frontend surfaces.** Top-level routes, design system folder if present, component library used.
54
+ - **Failure surfaces.** Logging, monitoring, error boundaries, retries.
55
+
56
+ ## Step 3 — Write the codebase map
57
+
58
+ Write `.cofoundr/memory/codebase.md`. Use this skeleton. Fill what you found. `<!-- GAP -->` what you didn't.
59
+
60
+ ```md
61
+ # Codebase Map — <project name from package.json or repo>
62
+
63
+ ## TL;DR
64
+ <60 words: language, framework, what kind of app, deployed where, who currently uses it>
65
+
66
+ ## Layout
67
+ <tree of the top 3 levels, monorepo or single>
68
+
69
+ ## Stack
70
+ | Layer | Tech | Version | Source |
71
+ |-------|------|---------|--------|
72
+ | Language | <e.g. TypeScript> | <e.g. 5.4> | tsconfig.json / package.json |
73
+ | Framework | ... | ... | ... |
74
+ | Database | ... | ... | ... |
75
+ | ORM | ... | ... | ... |
76
+ | Auth | ... | ... | ... |
77
+ | Testing | ... | ... | ... |
78
+ | CI/Deploy | ... | ... | ... |
79
+
80
+ ## Routes / Surfaces
81
+ <table: Method | Path | File | Auth required>
82
+
83
+ ## Data Model
84
+ <table: Table | Purpose | Has RLS/authorization | Foreign keys>
85
+
86
+ ## External Integrations
87
+ <table: Service | Used for | Env vars referenced>
88
+
89
+ ## Background Work
90
+ <list: cron, jobs, webhooks, scheduled tasks>
91
+
92
+ ## Existing Docs
93
+ <list every doc found, with one-sentence summary>
94
+
95
+ ## Existing AI surfaces
96
+ <list: which tools are already configured>
97
+
98
+ ## Gaps and Open Questions
99
+ - <!-- GAP: <one per missing thing> -->
100
+ ```
101
+
102
+ ## Step 4 — Backfill the constitution
103
+
104
+ If `.cofoundr/constitution.md` does not exist:
105
+
106
+ - Draft one from observed patterns. Examples of what observation buys you:
107
+ - If RLS is used everywhere, add an Always rule.
108
+ - If `any` appears in TypeScript, do **not** assume the project tolerates it — ask.
109
+ - If `.env.example` is comprehensive, add a Never-commit-secrets rule.
110
+ - If the repo has destructive scripts, add an Ask-first rule before running them.
111
+ - Mark every clause as `[draft — confirm]` so the founder reviews before it becomes binding.
112
+ - Run the founder through the `/cofoundr:constitution` confirmation flow.
113
+
114
+ ## Step 5 — Backfill the spec (best effort)
115
+
116
+ If `docs/product.md` and friends do not exist, draft a back-filled set in `.cofoundr/specs/_backfilled/`:
117
+
118
+ - `product.md` — derive the product definition from `README.md` + repo description. If both are thin, leave a GAP and ask the founder Q1, Q2, Q3, Q9 from `/cofoundr:plan`.
119
+ - `tech.md` — derive entirely from observation. This one should have very few gaps.
120
+ - `prd.md` — list the **observable** features (what the deployed app does). Do not invent P1/P2 — ask the founder which features were last shipped and which are still in flight.
121
+ - `phases.md` — produce a single "Already shipped" milestone listing what's there, and a "Next" milestone left empty for the founder to fill via `/cofoundr:next`.
122
+
123
+ Stamp the top of every back-filled file with:
124
+
125
+ ```
126
+ <!-- This file was back-filled by /cofoundr:onboard from the existing codebase.
127
+ Verify before treating as authoritative. Run /cofoundr:audit for drift. -->
128
+ ```
129
+
130
+ ## Step 6 — Update AGENTS.md
131
+
132
+ If `AGENTS.md` does not exist at the project root, create it from `scaffold/AGENTS.md.tmpl`. Append (or fill) a **Codebase** section pointing to `.cofoundr/memory/codebase.md`.
133
+
134
+ If `AGENTS.md` exists, do not overwrite it. Append a clearly-marked CoFoundr block:
135
+
136
+ ```
137
+ <!-- cofoundr:start -->
138
+ ## Codebase Map
139
+ The current architecture map lives at `.cofoundr/memory/codebase.md`.
140
+ Re-run `/cofoundr:onboard --refresh` after any architectural change.
141
+ <!-- cofoundr:end -->
142
+ ```
143
+
144
+ ## Step 7 — Report
145
+
146
+ Hand back to the founder:
147
+
148
+ ```
149
+ Onboard complete.
150
+
151
+ Wrote:
152
+ - .cofoundr/memory/codebase.md
153
+ - .cofoundr/constitution.md (draft, needs confirmation)
154
+ - .cofoundr/specs/_backfilled/{product.md, tech.md, prd.md, phases.md}
155
+ - AGENTS.md (created or appended)
156
+
157
+ Stack detected: <one line>
158
+ Routes: <count> Tables: <count> Integrations: <count>
159
+
160
+ Gaps that need you:
161
+ - <gap 1>
162
+ - <gap 2>
163
+ ...
164
+
165
+ Recommended next:
166
+ 1. /cofoundr:constitution — confirm and lock the rules.
167
+ 2. /cofoundr:audit — find drift between code, docs, and the back-filled spec.
168
+ 3. /cofoundr:document <module-or-route> — flesh out specific areas.
169
+ ```
170
+
171
+ ## What you must not do
172
+
173
+ - Do not modify any source file. Read-only on `src/`, `app/`, `lib/`, `pages/`, etc.
174
+ - Do not invent stack choices, framework versions, or features. If the code does not say it, do not write it.
175
+ - Do not print or transmit the contents of `.env*` files. Variable names only.
176
+ - Do not delete or replace existing `AGENTS.md`, `CLAUDE.md`, `README.md`. Append within fenced markers only.