@skyf0xx/hedgehog 0.1.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.
@@ -0,0 +1,171 @@
1
+ <!--
2
+ Hedgehog project CLAUDE.md template.
3
+
4
+ This file is copied into a consuming project's repo root at install
5
+ time. Placeholders wrapped in {{ }} are filled in once, at Intake, by
6
+ the `planner` agent (or by hand). Everything outside the placeholders is
7
+ a constant of the Hedgehog discipline and should be left as-is.
8
+
9
+ Delete this comment block after the placeholders are filled in.
10
+ -->
11
+
12
+ # {{PROJECT_NAME}}
13
+
14
+ {{PROJECT_SUMMARY — 2–4 sentences the `planner` writes at Intake: what
15
+ this project is, who it's for, and what it does. State current intent, not
16
+ history. Keep it tight — deeper domain context lives in the commit log and
17
+ docs/design, not here.}}
18
+
19
+ This project is built with **Hedgehog**: a backend-first, one-step-at-a-time
20
+ build discipline. The rules below aren't project preferences — they're how
21
+ the build stays mechanically correct. Follow them exactly.
22
+
23
+ ## How to work here
24
+
25
+ The build is a loop of small, gated, committed steps. You never hold the
26
+ whole plan in context — the plan lives in the structure:
27
+
28
+ - **`TODO.md`** is the live checklist and the source of truth for what's
29
+ next. Read it at the start of every session. Its only state is
30
+ checked/unchecked.
31
+ - **The commit log** is the record of what's built and why. Conventional
32
+ commits (`feat(<module>): schema`, `feat(<module>): api`, …) are how
33
+ progress is read, not a conversation summary.
34
+ - **The architecture is fixed and opinionated** — the same on every
35
+ Hedgehog project. Where a service lives, what it may import, the module
36
+ shape, the phase order: all of it is inferable from this file and the
37
+ skills *without reading a line of code*. You don't discover the
38
+ patterns; you already know them.
39
+ - **The codebase carries the project-specific instances** — which modules
40
+ exist, what a given schema's columns are, what's already wired. That,
41
+ you re-read from the code when you need it, rather than remembering it.
42
+
43
+ Because state lives in those places and not in the conversation, a fresh
44
+ context loses nothing: the architecture is known a priori, and the
45
+ project's specifics are re-read on demand. Use that (see **Managing
46
+ context** below).
47
+
48
+ ### The skills — invoke these, don't improvise
49
+
50
+ The discipline is packaged as skills. Use them; don't reconstruct their
51
+ steps from memory:
52
+
53
+ - **`hedgehog-loop`** — every unit of work once bootstrapped: pick the
54
+ next step from `TODO.md`, build exactly one, gate it, commit it, check
55
+ it off. Also holds the Correction Protocol for fixing a wrong upstream
56
+ step. Invoke it at the start of any build session and for "what's next".
57
+ - **`hedgehog-bootstrap`** — run **once**, at project start, to scaffold
58
+ the stack and the enforcement config. Skip if `nx.json` already exists.
59
+ - **`conventional-commits`** — when a change spans several steps in one
60
+ working-tree pass and needs splitting back into per-step commits (mainly
61
+ Correction Protocol cleanups).
62
+
63
+ ### The agents — delegate the judgment calls
64
+
65
+ - **`planner`** — Intake (scope boundary + domain vocabulary) at project
66
+ start, and module scoping when new scope enters play. Writes `TODO.md`
67
+ and `docs/design/<module>-notes.md`.
68
+ - **`ux-planner`** — once per module in Phase B, after the hook exists and
69
+ before the screen: writes `docs/design/<module>.md`.
70
+ - **`ui-builder`** — builds screens from the ux-planner rationale.
71
+ - **`reviewer`** — phase-transition and Correction Protocol checks the
72
+ mechanical gate can't make (port discipline, FK-by-ID discipline,
73
+ contract shape).
74
+
75
+ ## The constants (do not deviate)
76
+
77
+ ### Stack (locked)
78
+
79
+ Nx monorepo · pnpm · **NestJS** (all domain logic + DB access) · **Drizzle**
80
+ (+ `drizzle-zod`) · **PostgreSQL** · Railway · **ts-rest** contracts · **Zod**
81
+ validation · **Better Auth** · **TanStack Query** hooks · **Next.js** + ShadCN
82
+ + Tailwind (web, UI only) · Expo + React Native Reusables + NativeWind
83
+ (mobile, optional) · **BullMQ + Redis** (queues) · Pino logging · Vitest +
84
+ Playwright (tests) · Conventional Commits + commitlint + lefthook · Sentry.
85
+
86
+ Don't substitute libraries. If a package or generator name changed
87
+ upstream, verify against current docs before running — don't swap in a
88
+ different library.
89
+
90
+ ### Layout
91
+
92
+ ```
93
+ apps/
94
+ web Next.js — UI only
95
+ mobile Expo — optional
96
+ api NestJS — owns all domain logic + DB access
97
+ worker BullMQ consumers
98
+ packages/
99
+ db Drizzle schema + client
100
+ contracts ts-rest + Zod contracts
101
+ hooks TanStack Query — shared web + mobile
102
+ jobs typed job registry / queue definitions
103
+ auth Better Auth config
104
+ config locked ESLint/Prettier/tsconfig/env schema
105
+ shared cross-cutting types + utils
106
+ libs/
107
+ <module>/port · <module>/repository · <module>/service (one triplet per table)
108
+ docs/
109
+ design <module>-notes.md (Intake) and <module>.md (ux-planner)
110
+ ```
111
+
112
+ ### Core rules
113
+
114
+ - **One table = one domain module.** Each carries the full step sequence.
115
+ - **Cross-module references are FK-by-ID only.** A service imports only
116
+ its own ports — never another module's adapter. (Enforced by Nx module
117
+ boundaries; building out of order fails `nx lint`.)
118
+ - **Backend before frontend.** Phase A (schema → contract → repository →
119
+ service → controller → queue?) closes for a module before Phase B
120
+ (hooks → screen) opens. Enforced by the CI phase gate.
121
+ - **Sequential within a phase.** A step starts only once the previous one
122
+ compiles and passes tests.
123
+ - **One step = one commit**, in the exact Conventional Commit format from
124
+ `hedgehog-loop`. A commit that fails typecheck/lint/test does not happen
125
+ (lefthook gate).
126
+ - **Fix wrong steps at the source** via the Correction Protocol — never a
127
+ downstream workaround.
128
+ - **`packages/config` is the single source** for shared config. A per-app
129
+ override request means fix the base config, not add an override.
130
+
131
+ ## Consuming TODO.md
132
+
133
+ `TODO.md` at repo root is a thin checklist mirroring the phase/step
134
+ structure. To work from it:
135
+
136
+ 1. Read it. Find the first unchecked step whose gate (the step before it)
137
+ is satisfied.
138
+ 2. Confirm the phase: a module with a `feat(<module>): api` commit is in
139
+ Phase B; otherwise Phase A.
140
+ 3. Build that one step via `hedgehog-loop`.
141
+ 4. Check the line off after the commit lands. Checked/unchecked is the
142
+ only state — no notes, no rationale (that's the commit log's job).
143
+
144
+ `planner` owns writing and extending `TODO.md`; the loop only checks boxes
145
+ off. Keep it thin.
146
+
147
+ **When the build is done:** once every module in scope has both phases
148
+ checked, the build session is complete. **Delete `TODO.md`** — a finished
149
+ checklist is noise, and the commit log is the durable record of what was
150
+ built.
151
+
152
+ ## Managing context
153
+
154
+ Hedgehog is designed so the conversation is disposable. Keep the working
155
+ context small:
156
+
157
+ - **Clear context at module boundaries.** After a module's Phase A (or a
158
+ whole module) is done and committed, `/clear` and start fresh — re-read
159
+ `TODO.md` and continue. Nothing is lost, because the checklist, commits,
160
+ and code hold all the state. Prefer this over letting one session
161
+ accumulate the entire project.
162
+ - **A cleared or new session recovers by reading `TODO.md` + the commit
163
+ log**, never by needing the prior conversation.
164
+ - **Delegate heavy work to agents.** Intake elicitation (`planner`),
165
+ screen builds (`ui-builder`), and reviews (`reviewer`) each run in their
166
+ own isolated context — so that work doesn't pile up in the main thread.
167
+ - **Don't paste large context back in.** If you find yourself
168
+ re-explaining the architecture, stop — it's fixed and stated in this
169
+ file, not something to reconstruct. If you need a project specific, read
170
+ it from the code. That's the self-documenting design working as
171
+ intended.
@@ -0,0 +1,43 @@
1
+ # TODO
2
+
3
+ <!-- 2-3 sentences: what is this project. Link out to a deeper context
4
+ file (e.g. docs/context.md) only if the domain genuinely needs it — most
5
+ projects shouldn't need one. -->
6
+
7
+ ## Context
8
+
9
+ (fill in per project)
10
+
11
+ ## Bootstrap
12
+
13
+ - [ ] Nx workspace + `packages/config`
14
+ - [ ] `packages/db` — Drizzle client
15
+ - [ ] `packages/auth` — Better Auth config
16
+ - [ ] `apps/api` — Nest shell, global guard, Pino
17
+ - [ ] `apps/worker` — BullMQ seam (Redis, no consumers yet)
18
+ - [ ] `apps/web` — Next shell, TanStack Query provider
19
+ - [ ] `apps/mobile` — Expo shell (only if building for mobile)
20
+ ## Phase A — Backend
21
+
22
+ <!-- One subsection per module in scope. Do not add hooks/screens here —
23
+ that's Phase B, and doesn't start until every module below is checked. -->
24
+
25
+ ### <module-name>
26
+
27
+ - [ ] schema
28
+ - [ ] contract
29
+ - [ ] repository
30
+ - [ ] service
31
+ - [ ] api (controller)
32
+ - [ ] queue (only if this operation genuinely needs async)
33
+ ## Phase B — Frontend
34
+
35
+ <!-- Do not touch this section until every module above has "api" checked. -->
36
+
37
+ ### <module-name>
38
+
39
+ - [ ] hooks
40
+ - [ ] ux-planner — writes docs/design/<module-name>.md; ask for a
41
+ mockup/screenshot/Stitch or Figma export here if one exists
42
+ - [ ] screen-web
43
+ - [ ] screen-mobile (only if building for mobile)