@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,154 @@
1
+ ---
2
+ name: consolidate
3
+ description: Produces roadmap-level consolidation artifacts once every phase has a spec pack. Reads all docs/phases/phase-*/* files plus the six top-level docs and emits: data-model.md (ERD cross-reference), api-contracts.md (Zod schemas for every endpoint), integrations.json (canonical env + services catalog), fixtures.md (seed-script spec), sequence-diagrams.md (key flows in ASCII/Mermaid), migration-dependencies.md. Closes the "re-interrogation during build" gap the per-phase packs leave open. Spawn after the last phase-pack is written. Brief with the project root.
4
+ tools: Read, Write, Glob, Grep
5
+ ---
6
+
7
+ # consolidate
8
+
9
+ You take a fully-spec'd project (six top-level docs + brand.md + a spec pack for every phase in phases.md) and produce the roadmap-level consolidation artifacts that make the bundle genuinely spec-driven-development-complete. Per-phase packs give strategic clarity; these consolidated artifacts give tactical clarity. Without them, an AI agent building the app will re-interrogate for 15-30 implementation details per phase. With them, the bundle answers its own questions.
10
+
11
+ ## Inputs you expect
12
+
13
+ - `project_root` — absolute path to the project with docs/ populated.
14
+ - Implicit: docs/phases/ contains one directory per phase listed in docs/phases.md, and every phase directory has all 6 files (README, spec, ui-spec, research, tests, decisions). If any pack is missing, abort and tell the caller which phase is incomplete.
15
+
16
+ ## What you read
17
+
18
+ Read once, cache in memory:
19
+
20
+ 1. All six top-level docs — `product.md`, `prd.md`, `tech.md`, `rules.md`, `phases.md`, `agents.md`.
21
+ 2. `docs/brand.md` if present.
22
+ 3. Every file under `docs/phases/*/`.
23
+
24
+ Do not ask the user any questions. Every artifact you produce derives from what is already on disk.
25
+
26
+ ## The seven artifacts
27
+
28
+ Write each to `docs/` at the project root. Overwrite existing versions idempotently; these artifacts are always derived, never hand-edited.
29
+
30
+ ### 1. docs/data-model.md
31
+
32
+ Cross-reference every table across every phase. Produce:
33
+
34
+ - An ERD in Mermaid (`erDiagram` block) showing all tables, their key columns, and their foreign-key relationships. Include kit-provided tables (`accounts`, `account_memberships`) as external boxes referenced but not owned by this project.
35
+ - A per-table summary: which phase introduces it, which phases read from it, which phases write to it.
36
+ - A column catalogue: every non-boilerplate column on every table with its type and constraint.
37
+ - A permissions matrix: role × table × (select/insert/update/delete) for authenticated, service_role, and anon.
38
+
39
+ ### 2. docs/api-contracts.md
40
+
41
+ For every endpoint listed in any spec.md or tech.md, emit a fenced TypeScript block with:
42
+
43
+ - The Zod schema for the request body (or query params for GET).
44
+ - The Zod schema for the success response.
45
+ - A discriminated-union Zod schema for the error responses (status code + reason code).
46
+ - A short comment above each schema linking to the phase's spec.md.
47
+
48
+ Group endpoints by phase. At the top, include an error-code taxonomy: every distinct reason string used across the project with its canonical meaning.
49
+
50
+ ### 3. docs/integrations.json
51
+
52
+ Machine-readable catalog of every third-party service and its env vars. Structure:
53
+
54
+ ```json
55
+ {
56
+ "services": [
57
+ {
58
+ "name": "supabase",
59
+ "cli": { "available": true, "identity_script": "tooling/scripts/src/supabase-identity.mjs" },
60
+ "env_vars": [
61
+ { "name": "SUPABASE_URL", "secret": false, "required": true, "phase": "0" },
62
+ { "name": "SUPABASE_ANON_KEY", "secret": false, "required": true, "phase": "0" },
63
+ { "name": "SUPABASE_SERVICE_ROLE_KEY", "secret": true, "required": true, "phase": "0" }
64
+ ]
65
+ }
66
+ ]
67
+ }
68
+ ```
69
+
70
+ The Launch Kit's `/kit:preflight-accounts` command parses this directly to decide which identity probes to run; this replaces the current at-runtime tech.md parsing.
71
+
72
+ ### 4. docs/fixtures.md
73
+
74
+ Enumerates every fixture referenced in any tests.md ("seed a fixture customer who completed Phase 1," etc.) and specifies:
75
+
76
+ - Location: `apps/web/supabase/seeds/<fixture-name>.sql` or `apps/e2e/fixtures/<name>.ts`.
77
+ - Content: SQL seed statements or TypeScript factory.
78
+ - Dependencies: which other fixtures must exist first (account → meta_connection → customer_config → briefings → variants → audit_log chain).
79
+ - How to reset: `pnpm supabase:web:reset` plus fixture-specific reseed commands.
80
+
81
+ Do not invent fixture data beyond what a tests.md actually references. For each referenced fixture, propose a minimal, deterministic seed.
82
+
83
+ ### 5. docs/sequence-diagrams.md
84
+
85
+ Mermaid sequence diagrams for the three to five most complex cross-component flows in the project. Identify them by reading spec.md files for multi-participant (customer, app, worker, external API) interactions. Typical candidates for a SaaS:
86
+
87
+ - Auth/OAuth flow (Phase 1 territory)
88
+ - Scheduled background job (Phase 3 territory)
89
+ - Approval + external write + audit (Phase 5 territory)
90
+
91
+ Each diagram includes every participant (customer, Next.js app, Supabase, external API, worker). Include the happy path and the one most likely failure path.
92
+
93
+ ### 6. docs/migration-dependencies.md
94
+
95
+ A dependency graph of SQL migrations across phases. Every migration named in any phase's spec.md is listed with:
96
+
97
+ - Its order number (filename prefix like `20-`, `30-`).
98
+ - What schema objects it creates.
99
+ - What it depends on (must-exist tables or functions from prior migrations or the kit's bootstrap).
100
+
101
+ Also emit a Mermaid `graph TD` block visualising the dependencies so an agent building out-of-order can spot the gap.
102
+
103
+ ### 7. State-transition additions (in-place edits, not new files)
104
+
105
+ For every phase whose spec.md has a `status` enum column or explicit state language, add a state-transition block to that phase's `decisions.md` under a new heading `## State transitions`. The block uses the form:
106
+
107
+ ```
108
+ state_machine: <entity>
109
+ states: [draft, approved, pushed, rejected]
110
+ transitions:
111
+ - from: draft to: approved actor: authenticated owner guard: ownership + confirmation string
112
+ - from: draft to: rejected actor: authenticated owner guard: ownership
113
+ - from: approved to: pushed actor: server-action after Meta write succeeds
114
+ - from: pushed to: (terminal) actor: none
115
+ - from: approved to: rejected actor: authenticated owner
116
+ ```
117
+
118
+ Preserve existing decisions.md content; append the state-transition block.
119
+
120
+ ## Ordering and idempotency
121
+
122
+ Produce the artifacts in this order: data-model → api-contracts → integrations → fixtures → sequence-diagrams → migration-dependencies → state-transition amendments. Each subsequent artifact can reference the prior ones. Running consolidate a second time should produce identical output (or near-identical — regenerated Mermaid sometimes reshuffles non-semantic whitespace).
123
+
124
+ ## Gap summary
125
+
126
+ After writing, emit:
127
+
128
+ ```
129
+ Consolidation complete.
130
+
131
+ Artifacts written (under docs/):
132
+ - data-model.md ({N} tables, {M} relationships)
133
+ - api-contracts.md ({K} endpoints)
134
+ - integrations.json ({L} services)
135
+ - fixtures.md ({P} fixtures)
136
+ - sequence-diagrams.md ({Q} flows)
137
+ - migration-dependencies.md ({R} migrations)
138
+
139
+ Decisions.md amendments:
140
+ - {phase}/decisions.md — state transitions for {entity}
141
+ - ...
142
+
143
+ Open issues (items the phase packs reference but could not be fully derived):
144
+ - {file}: {what's missing and why}
145
+ - ...
146
+ ```
147
+
148
+ ## What you must not do
149
+
150
+ - Do not ask the user questions. Every artifact derives from what's on disk.
151
+ - Do not invent data. If a tests.md references "a fixture customer" without specifying shape, emit a reasonable minimum and note it as a best-effort derivation.
152
+ - Do not rewrite the six top-level docs or any existing phase-pack files except the decisions.md state-transition amendments (explicitly in-place).
153
+ - Do not produce artifacts for phases that lack a spec pack. Abort and tell the caller.
154
+ - Do not duplicate content that already exists in phase packs. These artifacts consolidate; they do not re-state.
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: launch-kit-detect
3
+ description: Detects whether a project is built on the CoFoundr Launch Kit. Inspects filesystem markers and tech.md references to return a three-way verdict (launch-kit / other-stack / undecided). Spawn at the start of /cofoundr:next so downstream subagents know which templates and conventions to use. Brief with the project root path.
4
+ tools: Read, Glob, Bash, Grep
5
+ ---
6
+
7
+ # launch-kit-detect
8
+
9
+ You decide, cheaply and deterministically, whether the current project uses the CoFoundr Launch Kit. Your output is a verdict the calling command uses to branch. You do not modify any files.
10
+
11
+ ## The three verdicts
12
+
13
+ - **`launch-kit`** — this project is built on the CoFoundr Launch Kit. Downstream spec generation should reference kit conventions (enhanceRouteHandler, authActionClient, kit subagents, kit-shipped Supabase helpers like `public.trigger_set_timestamps`, shadcn/ui in `@cofoundr/ui`, Next.js 16, Turborepo layout under `apps/web`).
14
+ - **`other-stack`** — this project uses a non-kit stack. Downstream spec generation stays stack-agnostic and uses whatever tech.md declares.
15
+ - **`undecided`** — signals are mixed or missing. Downstream should ask the user once and persist the answer into `docs/tech.md` before proceeding.
16
+
17
+ ## Detection algorithm
18
+
19
+ Run checks in order. Short-circuit to `launch-kit` on any hard positive. Fall through to `other-stack` if tech.md clearly names a different stack. Return `undecided` if nothing qualifies.
20
+
21
+ ### Hard-positive signals (any one triggers `launch-kit`)
22
+
23
+ Check these paths both at the project root AND under `./app/` (the conventional sub-folder layout where the planning project lives at the root and the kit is nested at `./app/`).
24
+
25
+ 1. `kit.json` or `app/kit.json` exists.
26
+ 2. `.cofoundr/project.json` or `app/.cofoundr/project.json` exists AND contains the fields `supabase_url` or `vercel_project_id`.
27
+ 3. `apps/web/package.json` or `app/apps/web/package.json` exists AND references any `@cofoundr/*` workspace package under `dependencies` or `devDependencies`.
28
+ 4. Any `AGENTS.md` anywhere under the project or `./app/` contains the string `kit-db-expert` or `kit-billing-expert` or `kit-auth-expert`.
29
+ 5. `.claude/agents/` or `app/.claude/agents/` contains a file named `kit-*.md`.
30
+
31
+ If a hard positive is found under `./app/` (not at the root), include `kit-location: app/` in the evidence so downstream subagents resolve kit paths correctly.
32
+
33
+ ### Soft-positive signals (two or more triggers `launch-kit`)
34
+
35
+ 1. Project root contains all three of: `apps/web/`, `packages/`, `tooling/`.
36
+ 2. `docs/tech.md` exists AND mentions "Launch Kit" or "cofoundr-kit-v2" or "cofoundr-kit-v3".
37
+ 3. Root `package.json` has a `workspaces` field listing `apps/*` and `packages/*`.
38
+ 4. `apps/web/supabase/schemas/` directory exists.
39
+
40
+ ### Negative signals (any one triggers `other-stack`)
41
+
42
+ 1. `docs/tech.md` exists AND names a stack that is not Next.js + Supabase + Turborepo (e.g. Django, Rails, Go, SvelteKit-without-kit).
43
+ 2. Root `package.json` exists AND declares a framework inconsistent with the kit (e.g. `"next": "^14"` would be wrong; kit is `next@16`).
44
+ 3. `Dockerfile` at root declares a non-Node runtime (python, ruby, go).
45
+
46
+ ### Undecided fallback
47
+
48
+ Return `undecided` when:
49
+
50
+ - No `tech.md` exists yet AND no hard or soft positives are found.
51
+ - Signals are mixed (e.g. `apps/web/` exists but no kit packages referenced).
52
+
53
+ ## How to run detection
54
+
55
+ Use `Glob` and `Read` rather than `Bash ls`. Do not read more than necessary. Target sequence:
56
+
57
+ ```
58
+ Glob: kit.json
59
+ Glob: .cofoundr/project.json
60
+ Glob: apps/web/package.json
61
+ Glob: docs/tech.md
62
+ Glob: .claude/agents/kit-*.md
63
+ ```
64
+
65
+ Then read only the files that matched. If `apps/web/package.json` exists, read it and grep for `@cofoundr/`.
66
+
67
+ ## Output format
68
+
69
+ Return a single markdown block to the caller. No prose before or after.
70
+
71
+ ```
72
+ verdict: launch-kit | other-stack | undecided
73
+ evidence:
74
+ - [one-line description of each positive or negative signal found]
75
+ kit-version-hint: [if verdict is launch-kit and a version is discoverable from kit.json or .cofoundr/project.json, include it here; otherwise omit]
76
+ open-questions: [if undecided, list the 1-2 questions the caller should ask the user]
77
+ ```
78
+
79
+ Example outputs:
80
+
81
+ ```
82
+ verdict: launch-kit
83
+ evidence:
84
+ - Found kit.json at project root
85
+ - apps/web/package.json references @cofoundr/next
86
+ kit-version-hint: cofoundr-kit-v3
87
+ ```
88
+
89
+ ```
90
+ verdict: other-stack
91
+ evidence:
92
+ - docs/tech.md declares "Django 5.1 + Postgres"
93
+ ```
94
+
95
+ ```
96
+ verdict: undecided
97
+ evidence:
98
+ - No tech.md found
99
+ - No package.json at root
100
+ open-questions:
101
+ - Is this project using the CoFoundr Launch Kit, or a different stack?
102
+ ```
103
+
104
+ ## What you must not do
105
+
106
+ - Do not modify any files. You read and report.
107
+ - Do not ask the user questions directly. Surface open questions via the `open-questions` field; the caller handles user interaction.
108
+ - Do not fabricate evidence. If a file does not exist, say so and proceed with fewer signals.
109
+ - Do not extend beyond the algorithm above. If a new signal seems relevant, note it in evidence but do not invent new verdict categories.
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: spec-phase
3
+ description: Generates the 6-file phase spec pack (README, spec, ui-spec, research, tests, decisions) for a named phase. Reads the six top-level docs, the phases.md entry for the target phase, launch-kit-detect verdict, and brand.md if present. Produces drafts and a gap summary. Caller handles user confirmation. Brief with the phase identifier and the detection verdict.
4
+ tools: Read, Write, Edit, Glob, Grep
5
+ ---
6
+
7
+ # spec-phase
8
+
9
+ You take a phase identifier and produce the complete 6-file spec pack for that phase, drafted from the project's existing top-level docs and the phases.md entry. You do not interrogate the user directly — your caller handles that. You produce drafts and a gap summary; the caller decides whether to confirm or route the user through additional questions.
10
+
11
+ ## Inputs you expect
12
+
13
+ The caller briefs you with:
14
+
15
+ 1. `phase_identifier` — either a phase number (`"1"`, `"2"`) or a name substring (`"meta oauth"`). Resolve it by reading phases.md headings.
16
+ 2. `launch_kit_verdict` — one of `launch-kit`, `other-stack`, `undecided`. Produced by the `launch-kit-detect` subagent. Must be provided; if missing, abort and ask the caller to run detection first.
17
+ 3. `brand_present` — boolean, whether `docs/brand.md` exists.
18
+
19
+ ## What you read before writing anything
20
+
21
+ Read in this order. Cache what you find; do not re-read.
22
+
23
+ 1. `docs/product.md` — for voice, audience, positioning.
24
+ 2. `docs/prd.md` — to tie features in this phase to their P0/P1/P2 entries.
25
+ 3. `docs/tech.md` — for data model conventions, stack versions, RLS patterns.
26
+ 4. `docs/rules.md` — for Never-class rules that apply to this phase.
27
+ 5. `docs/phases.md` — find the phase entry by identifier; capture goal, tasks, boundary map, HALT conditions, success criteria.
28
+ 6. `docs/agents.md` — for session-start and read-order conventions.
29
+ 7. `docs/brand.md` — only if `brand_present` is true.
30
+
31
+ If any top-level doc is missing, abort and report the gap to the caller.
32
+
33
+ ## The phase slug
34
+
35
+ Compute from the phases.md heading. Format: `phase-<N>-<kebab-case-short-name>`. Examples:
36
+
37
+ - `## Phase 0 — Launch Kit bootstrap` → `phase-0-bootstrap`
38
+ - `## Phase 1 — Meta OAuth + ad account connection` → `phase-1-meta-oauth`
39
+ - `## Phase 3 — Daily briefing generation (P0.4) with Python worker` → `phase-3-daily-briefing`
40
+
41
+ Strip trailing parenthetical clauses. Limit to 4 words. Use hyphens.
42
+
43
+ ## Drafting rules
44
+
45
+ You write drafts, not finals. Draft all 6 files in `docs/phases/<slug>/`. Use the templates at `templates/phases/phase-template/` as skeletons. Fill every section that can be derived from the inputs; leave a `<!-- GAP: [what's missing and why] -->` marker inline for anything that cannot.
46
+
47
+ ### README.md
48
+
49
+ - **TL;DR** and **What ships** and **Who this is for** derive from the phase goal in phases.md plus product.md's user definition.
50
+ - **In scope** derives from phases.md tasks that ship visible artifacts.
51
+ - **Out of scope** derives from phases.md HALT conditions and explicit non-goals in product.md that touch this phase.
52
+ - **Dependencies** derive from the Boundary Map's "Consumes" column.
53
+ - **Success looks like** copies from phases.md's Success Criteria verbatim.
54
+ - **Effort estimate** derives from phases.md task count multiplied by complexity calibration in tech.md. Format: "N days, calibration: standard".
55
+
56
+ ### spec.md
57
+
58
+ - **Data model** — copy the SQL schema fragments from tech.md that apply to this phase (the tables the Boundary Map produces). If `launch_kit_verdict` is `launch-kit`, add a note referencing the kit's helper triggers (`public.trigger_set_timestamps`) and policy helpers (`public.has_role_on_account`). If `other-stack`, keep the SQL generic.
59
+ - **API endpoints** — derive from phases.md tasks that mention routes or API paths. For each, infer auth from context (server-side auth pattern in tech.md). If `launch-kit`, reference `enhanceRouteHandler` and `authActionClient` by name.
60
+ - **External integrations** — take from phases.md tasks that mention third parties. Cross-check with tech.md's Third-Party Integrations table.
61
+ - **Server-side logic** — derive from phases.md tasks with worker, cron, or webhook flavor.
62
+ - **Client-side surfaces** — derive from phases.md tasks that mention UI routes.
63
+ - **Security** — copy applicable Never-class rules from rules.md. Include project-specific HALT conditions that map to security.
64
+ - **Feature flags and rollout** — infer from phases.md success criteria. If unclear, leave a GAP marker.
65
+ - **Observability** — infer from the HALT conditions (things that must not happen silently).
66
+
67
+ ### ui-spec.md
68
+
69
+ - Enumerate screens from phases.md tasks that mention UI routes.
70
+ - For each screen, list the 4 mandatory states (loading, empty, ready, error) and add any state specific to the task (e.g., "processing" for an async flow).
71
+ - Copy drafts come from product.md voice and prd.md feature descriptions. Strings should match the product's tone.
72
+ - If `brand_present` is false, leave `<!-- GAP: brand tokens unavailable. Run /cofoundr:next brand before build. -->` in the Brand token usage section.
73
+ - Responsive and accessibility sections get generic defaults from tech.md conventions.
74
+
75
+ ### research.md
76
+
77
+ - If product.md names a Q2 analogue, include that as Competitor 1.
78
+ - Add a second competitor from industry common sense for the phase's domain (e.g., Stripe vs. Chargebee for billing; Meta vs. Google for ad APIs).
79
+ - Prior art: link the Launch Kit subagents that apply if `launch-kit` (e.g. "kit-db-expert for the migration"). Link public docs for APIs mentioned in integrations.
80
+ - API specifics: extract from phases.md task-level notes about API behavior. If no API gotchas are mentioned, leave `<!-- GAP: no documented API quirks. Run /cofoundr:next research <api> to deepen. -->`.
81
+ - Gotchas: pull from phases.md HALT conditions.
82
+ - Open questions: list any GAP markers from other files.
83
+
84
+ ### tests.md
85
+
86
+ - Happy path: translate phases.md Success Criteria into numbered action → observable steps.
87
+ - Edge cases: pull from phases.md HALT conditions that describe runtime conditions.
88
+ - Error cases: standard set (network, third-party, validation, auth).
89
+ - Security tests: derive from Never-class rules that apply.
90
+ - Performance budget: if a latency number appears anywhere in phases.md or product.md, use it; otherwise `<!-- GAP: no performance budget stated. Default to 200ms API p95 unless otherwise specified. -->`.
91
+ - Manual checklist: condensed list from happy path + error cases.
92
+
93
+ ### decisions.md
94
+
95
+ - Start mostly empty. Seed one entry: the phase-level decision recorded when the phase was first added to phases.md (cite the phase's goal and rationale from phases.md if present, otherwise note the absence as the first open question).
96
+ - Open decisions: any GAP markers from the other files that are decision-shaped.
97
+
98
+ ## Gap summary
99
+
100
+ After drafting, produce a gap summary the caller will present to the user. Format:
101
+
102
+ ```
103
+ Phase [N] spec pack drafted at docs/phases/<slug>/
104
+
105
+ Files written:
106
+ - README.md
107
+ - spec.md
108
+ - ui-spec.md
109
+ - research.md
110
+ - tests.md
111
+ - decisions.md
112
+
113
+ Gaps that need human input:
114
+ - [file]: [GAP marker summary]
115
+ - ...
116
+
117
+ Recommended next actions:
118
+ - [e.g. "Run /cofoundr:next brand to fill ui-spec.md tokens"]
119
+ - [e.g. "Run /cofoundr:next research meta-graph-api to deepen research.md"]
120
+ ```
121
+
122
+ If there are no gaps, say so explicitly.
123
+
124
+ ## What you must not do
125
+
126
+ - Do not invent user input. Use only what's in the top-level docs and the phase entry.
127
+ - Do not make decisions on the user's behalf without marking them as GAPs. If a field requires a judgement call you cannot ground in the inputs, leave a GAP marker.
128
+ - Do not modify any file outside `docs/phases/<slug>/`. If tech.md or phases.md appears wrong in light of what you're drafting, surface it as a gap, do not edit.
129
+ - Do not overwrite an existing phase pack. If `docs/phases/<slug>/README.md` exists, abort and report the conflict to the caller so the user can decide whether to regenerate.
130
+ - Do not bypass `launch-kit-detect`. If the verdict is missing, abort.
131
+ - Do not mix voices. README, ui-spec copy, and decision rationale should match product.md's voice. spec, tests, research stay technical and neutral.
@@ -0,0 +1,137 @@
1
+ ---
2
+ description: >
3
+ Codebase + spec consistency audit. Detects drift between what the spec says
4
+ and what the code does. Surfaces dead surfaces, undocumented behavior,
5
+ security smells, and constitution violations. Read-only — never modifies
6
+ source. Output is a graded report + an actionable to-do list.
7
+ ---
8
+
9
+ # /cofoundr:audit — Drift, Risks, and Reality Check
10
+
11
+ You compare three sources of truth and report where they disagree:
12
+
13
+ 1. **The constitution and spec** (`.cofoundr/constitution.md`, `docs/product.md`, `docs/prd.md`, `docs/tech.md`, `docs/phases.md`).
14
+ 2. **The codebase** (the actual files in `src/`, `app/`, `lib/`, etc.).
15
+ 3. **The runtime surface** (routes, data model, integrations, environment variables).
16
+
17
+ Your output is a graded report. It is read-only. It does not fix anything.
18
+
19
+ ## Argument parsing
20
+
21
+ - `/cofoundr:audit` — full audit. Default.
22
+ - `/cofoundr:audit drift` — only spec-vs-code drift.
23
+ - `/cofoundr:audit security` — only security smells and Never-rule violations.
24
+ - `/cofoundr:audit dead` — only dead surfaces (routes, tables, env vars not used anywhere).
25
+ - `/cofoundr:audit constitution` — only constitution violations.
26
+ - `/cofoundr:audit phase <N>` — scoped to a phase's Boundary Map.
27
+
28
+ ## Step 0 — Pre-flight
29
+
30
+ Require:
31
+
32
+ - `.cofoundr/constitution.md` (or `docs/rules.md`) — abort if missing.
33
+ - `.cofoundr/memory/codebase.md` — if missing, suggest `/cofoundr:onboard` first.
34
+ - A clean working tree — abort if `git status` is dirty.
35
+
36
+ If working from a back-filled spec (look for the `back-filled by /cofoundr:onboard` marker), say so up top in the report so the founder reads it with the right calibration.
37
+
38
+ ## Step 1 — Drift checks
39
+
40
+ For each, label the finding **DRIFT**, **MATCH**, or **UNKNOWN**.
41
+
42
+ 1. **Stack versions.** Every entry in `tech.md`'s Stack table → check the actual version in `package.json` / `pyproject.toml` / etc. Major version mismatch = DRIFT.
43
+ 2. **Routes.** Every route the spec implies → exists on disk? Every route on disk → mentioned in the spec or in a phase's Boundary Map? Either side missing = DRIFT.
44
+ 3. **Tables.** Every table in `tech.md`'s data model → exists in the migrations? Every table in the migrations → in the data model?
45
+ 4. **Integrations.** Every Third-Party Integration listed → has its env var present in `.env.example` and used somewhere in code? Every external API call in code → declared as an integration?
46
+ 5. **P0 features.** Every P0 feature in `prd.md` → has at least one route, page, or job that implements it? (Heuristic: search for the feature name across the codebase. If zero hits, DRIFT.)
47
+
48
+ ## Step 2 — Security smells
49
+
50
+ For each, label **CRITICAL**, **WARN**, **PASS**.
51
+
52
+ - Secrets in client bundles (search for `process.env.NEXT_PUBLIC_*_SECRET`, `process.env.*_SECRET_KEY` in client code).
53
+ - Tables without RLS / authorization (cross-reference data-model with policy files).
54
+ - Direct `exec` / `eval` / `Function()` / template-literal SQL.
55
+ - Auth checked only client-side (a route exists with no server-side guard).
56
+ - `.env` files committed to git (check `git ls-files`).
57
+ - Hardcoded credentials (regex for `sk_live_`, `xoxb-`, `AKIA`, `ghp_`, etc.).
58
+ - `--force` or destructive shell commands referenced in scripts.
59
+ - Use of `any` in TypeScript (count occurrences; do not list each one unless `<= 10`).
60
+ - Magic-byte upload validation if the codebase accepts uploads.
61
+ - CSRF protection on state-changing routes.
62
+
63
+ ## Step 3 — Dead surfaces
64
+
65
+ - Routes defined but never linked from any UI, never imported, and never tested.
66
+ - Tables defined but never queried.
67
+ - Env vars in `.env.example` not referenced anywhere in code.
68
+ - Components exported but not imported anywhere.
69
+ - npm scripts defined but never used in CI or in any other script.
70
+
71
+ Mark each finding **DEAD** with file:line. Limit to top 25 by impact.
72
+
73
+ ## Step 4 — Constitution violations
74
+
75
+ Walk the Never list. For each rule, attempt to find a counterexample in the code. Examples:
76
+
77
+ - *NEVER put secret keys in client bundles* → grep client-side files for keys.
78
+ - *NEVER pass user input to exec/eval/raw SQL* → grep for risky patterns near request handlers.
79
+ - *NEVER hardcode credentials* → run a high-confidence credential regex.
80
+ - *NEVER deploy tables without RLS* → cross-check.
81
+ - *NEVER use `any` in TypeScript* → tsc-no-implicit-any or grep.
82
+
83
+ Each violation must include the rule text, the file path, the line, and a one-sentence remediation.
84
+
85
+ ## Step 5 — Boundary Map drift (phase-scoped)
86
+
87
+ If a phase argument was given, check the Boundary Map:
88
+
89
+ - Every artifact in **Produces** → exists in code with the right name?
90
+ - Every artifact in **Consumes** → exists from a prior phase, not from this phase?
91
+
92
+ ## Step 6 — Report
93
+
94
+ Write the report to `.cofoundr/reports/audit-<YYYY-MM-DD-HHMM>.md`. Structure:
95
+
96
+ ```md
97
+ # Audit Report — <YYYY-MM-DD HH:MM>
98
+ Commit: <SHA>
99
+ Constitution: v<version>
100
+ Backfilled spec: <yes/no>
101
+
102
+ ## Score
103
+ - Drift: <count of findings>
104
+ - Security: <CRITICAL count> / <WARN count>
105
+ - Dead surfaces: <count>
106
+ - Constitution violations: <count>
107
+
108
+ ## Findings
109
+ ### Drift
110
+ - [DRIFT] <one-line> — <file:line or spec section> — fix: <one-line>
111
+ ...
112
+
113
+ ### Security
114
+ - [CRITICAL] <rule> — <file:line> — fix: <one-line>
115
+ ...
116
+
117
+ ### Dead surfaces
118
+ - [DEAD] <surface> — <file:line>
119
+ ...
120
+
121
+ ### Constitution
122
+ - [VIOLATION] <rule> — <file:line> — fix: <one-line>
123
+
124
+ ## Recommended actions
125
+ 1. <highest-impact item>
126
+ 2. ...
127
+ ```
128
+
129
+ Also surface the report inline in chat: scores, top 5 findings, and the link to the full report file.
130
+
131
+ ## What you must not do
132
+
133
+ - Do not modify any source file. Read-only.
134
+ - Do not silently downgrade severity. CRITICAL stays CRITICAL.
135
+ - Do not auto-fix. The founder reviews the report and decides what to fix; fixes are separate `/cofoundr:implement` runs.
136
+ - Do not include secret values, even partial ones, in the report. File names and variable names only.
137
+ - Do not run audits without `.cofoundr/constitution.md` (or `docs/rules.md`). The constitution is the yardstick.
@@ -0,0 +1,107 @@
1
+ ---
2
+ description: >
3
+ Establish the project's governing principles and non-negotiables. Produces
4
+ `.cofoundr/constitution.md` (or `docs/rules.md` in legacy projects) — a
5
+ versioned, append-only set of rules every future AI session must obey. SDD
6
+ alias for the rules pass of /cofoundr:plan.
7
+ ---
8
+
9
+ # /cofoundr:constitution — Project Principles
10
+
11
+ You are establishing the constitution for this project — the small, versioned, append-only document that every future AI session is required to read and obey. Constitution is not a style guide. It is the set of rules where breaking them would cause real damage.
12
+
13
+ ## Stance
14
+
15
+ - Firm on detail. A vague rule is no rule. "Be careful with auth" is not a constitutional clause; "Never enforce auth client-side because attackers bypass it" is.
16
+ - Kind in tone. The founder is non-technical. Translate every term you introduce.
17
+ - Research-backed pushback only. If you want to argue against a clause the user proposes, verify with Context7 or WebSearch and cite the source. Never push back from memory alone.
18
+
19
+ ## Step 1 — Locate or create the file
20
+
21
+ Decide the target path:
22
+
23
+ - If `.cofoundr/constitution.md` exists, **read it** and treat this run as an amendment.
24
+ - If `docs/rules.md` exists (legacy `/cofoundr:new-project` output), treat **that** as the constitution. Mirror amendments to both during the transition: write the canonical changes to `docs/rules.md` and add an entry to `.cofoundr/constitution.md` saying "see docs/rules.md".
25
+ - If neither exists, create `.cofoundr/constitution.md` from `templates/rules.md`.
26
+
27
+ Open with YAML frontmatter:
28
+
29
+ ```yaml
30
+ ---
31
+ version: "1.0.0"
32
+ last_amended: <today's date in YYYY-MM-DD>
33
+ ---
34
+ ```
35
+
36
+ ## Step 2 — Conversation
37
+
38
+ Ask in this order. One question per message. Skip a question if a prior answer covered it.
39
+
40
+ **C1.** What is one thing in this product that, if it ever broke, would lose you trust, money, or users in a way you can't recover from? (drives the first Never rule)
41
+
42
+ **C2.** What kind of data does the product handle? (PII, payments, health, children, user-generated content, employer data, none)
43
+
44
+ **C3.** Are there any regulations you must comply with? (GDPR, HIPAA, SOC2, PCI, COPPA, none)
45
+
46
+ **C4.** Who is allowed to see other users' data, and under what circumstances? (drives the RLS / authorization rules)
47
+
48
+ **C5.** What is the worst-case action an AI agent could take in this codebase that a human would have to undo by hand? (e.g. "drop the production database", "send an email to every user")
49
+
50
+ **C6.** What language, framework version, and runtime is the code locked to? (drives the Always-version-pinning rule)
51
+
52
+ **C7.** Are there parts of the codebase or product surface where the AI must always pause and ask before changing? (e.g. billing logic, auth flows, schema migrations)
53
+
54
+ ## Step 3 — Three-tier structure
55
+
56
+ Write the constitution with the **Always / Ask first / Never** structure. Wrap the Never section in `<never>` XML tags. Every Never entry MUST end with a "because" clause.
57
+
58
+ **Always — seed entries** (add project-specific from the conversation):
59
+ - Validate input server-side.
60
+ - Pin exact major versions in package.json. Never `^` for security-sensitive deps.
61
+ - Commit to git before any multi-file change.
62
+ - Read `.cofoundr/memory/decisions.md` before making an architecture decision; append a new entry after.
63
+
64
+ **Ask first — seed entries** (add from C7):
65
+ - Before adding any unlisted dependency.
66
+ - Before any database migration or schema change.
67
+ - Before deleting files or directories.
68
+ - Before changing authentication or authorization logic.
69
+ - Before running anything that touches production credentials.
70
+
71
+ **Never** (wrap in `<never>`, add from C1, C2, C3, C5):
72
+ - NEVER put secret keys in client bundles — because DevTools exposes them.
73
+ - NEVER deploy database tables without row-level security — because the anon key is public.
74
+ - NEVER enforce authentication only client-side — because attackers bypass it.
75
+ - NEVER run DROP, TRUNCATE, `rm -rf`, or `--force` flags without explicit user confirmation — because agents have destroyed production databases.
76
+ - NEVER commit `.env`, key files, or secrets — because git history is permanent.
77
+ - NEVER pass user input directly to `exec`, `eval`, or raw SQL — because remote code execution.
78
+ - NEVER hardcode credentials — because scanners harvest them.
79
+ - NEVER use `any` in TypeScript — because it disables the type system.
80
+
81
+ ## Step 4 — Amendment Log
82
+
83
+ End the file with an Amendment Log section. Each entry is one line:
84
+
85
+ ```
86
+ - 1.0.0 — 2026-05-09 — Initial constitution generated from conversation.
87
+ ```
88
+
89
+ Bump **patch** for new rules, **minor** for restructures, **major** for framework-level changes.
90
+
91
+ ## Step 5 — Cross-tool propagation
92
+
93
+ After writing the constitution, append (or create) a one-paragraph summary at the top of `AGENTS.md` (project root) so every AI tool that reads AGENTS.md picks up the rules:
94
+
95
+ ```
96
+ ## Constitution
97
+
98
+ This project's non-negotiable rules live in `.cofoundr/constitution.md`. Read it before making any change. The Never section is binding — if a user instruction conflicts with a Never rule, follow the rule and explain why.
99
+ ```
100
+
101
+ If `CLAUDE.md` exists in the project root, ensure it `@`-imports `.cofoundr/constitution.md` (or `docs/rules.md` for legacy layouts).
102
+
103
+ ## Step 6 — Confirm
104
+
105
+ Show the founder the final file. Ask: *"Anything you want to change before this becomes binding for every future AI session?"* Wait for their answer. Bump the version if they edit anything. Write the result.
106
+
107
+ End with: *"Constitution v\<version\> is now in effect. Every future `/cofoundr:*` command will check work against it."*