feat(generators): onboarder and scaffolder emit docker/testing/ci path rules from templates/project-rules

This commit is contained in:
bchanot committed 2026-10-26 17:55:01 +01:00
1 parent 041e04b1d6
commit dbd20dd575
7 files changed
+86

No files matched your search

+18
View File
@@ -128,6 +128,24 @@ ls ${PROJECT_ROOT}/.claude/tasks/TODO.md ${PROJECT_ROOT}/.claude/memory/ 2>/dev/
**Do NOT overwrite existing content.**
## PHASE 5b — PATH-SCOPED RULES (born split)
For each of `docker`, `testing`, `ci`:
```bash
bash ~/.claude/lib/project-rules.sh -C <PROJECT_ROOT> emit ~/.claude/templates/project-rules/<name>.md .claude/rules/<name>.md
```
- rc 0 → written with the globs that match this tree; its stub comments
are `<!-- TODO(/onboard STEP 3): … -->` placeholders the orchestrator's
STEP 3 fills (list them in OUTPUT beside the CLAUDE.md placeholders).
Fill now only what the BRIEF already settles (`docker` commands from
`build_cmd`, `testing` layout from `test_cmd`); never duplicate the
always-on Build/Test sections.
- rc 1 → no match, nothing written, skip silently.
- rc 2 → the file exists: keep it, never overwrite.
Then `bash ~/.claude/lib/project-rules.sh -C <PROJECT_ROOT> check` must print
`N rule(s) ok`. The `!.claude/rules/` negation comes from the gitflow socle
at /onboard STEP 2.6 (`gitflow init` reconciles it); PHASE 4 stays as is.
---
## PHASE 6 — GSD v2 ROADMAP (optional, per orchestrator flag)
+19
View File
@@ -73,6 +73,25 @@ Empty structure only: imports + empty main/init. No logic.
`.dockerignore`: node_modules, .git, .env, dist/build/target, __pycache__.
Add `COMPOSE_PROJECT_NAME=<slug>` to `.env.example`.
## PHASE 3b — PATH-SCOPED RULES (born split)
After PHASE 3 wrote the files and BEFORE PHASE 4 installs dependencies
(installed packages must not match the globs). `<PROJECT_ROOT>` is the
project root PHASE 1 wrote `CLAUDE.md` into, as a literal absolute path
(`pwd` there; it is not an INPUT, the scaffold defines it). For each of
`docker`, `testing`, `ci`, one uniform loop:
```bash
bash ~/.claude/lib/project-rules.sh -C <PROJECT_ROOT> emit ~/.claude/templates/project-rules/<name>.md .claude/rules/<name>.md
```
rc 0 → fill its stubs from the DESIGN (image, compose services, test
layout, pipeline jobs), no placeholders left; rc 1 → nothing matched,
skipped (a plain scaffold yields `docker.md` when Docker is relevant, and
`testing.md` only when the stack scaffolds a test file). Then
`bash ~/.claude/lib/project-rules.sh -C <PROJECT_ROOT> check` prints
`N rule(s) ok`. The `.gitignore` negation `!.claude/rules/` comes from the
gitflow socle at STEP 5f (`gitflow init` reconciles it before the root
commit); do not add `.claude` lines to the stack `.gitignore` yourself.
---
## PHASE 4 — INSTALL DEPS
+18
View File
@@ -182,5 +182,23 @@ check T11b-four-rules "$(printf '%s\n' "$out" | grep -c '4 rule(s) ok')" 1
check T11c-transient-skipped \
"$(printf '%s\n' "$out" | grep -c 'transient-artifacts.md: SKIP docs/superpowers/\*\*')" 1
# T12 skeletons: emit keeps the matching globs only, skips when none match
mkdir -p "$FIX/gen/tests" && cd "$FIX/gen" || exit 1
echo x > Dockerfile; echo y > tests/test_a.py
bash "$PR" emit "$ROOT/templates/project-rules/docker.md" .claude/rules/docker.md >/dev/null
check T12-docker-emitted "$?" 0
check T12b-docker-globs-pruned "$(sed -n '2p' .claude/rules/docker.md)" 'paths: ["Dockerfile*"]'
check T12c-docker-body-kept "$(grep -c '^# Docker' .claude/rules/docker.md)" 1
bash "$PR" emit "$ROOT/templates/project-rules/testing.md" .claude/rules/testing.md >/dev/null
check T12d-testing-emitted "$?" 0
check T12e-testing-globs-pruned "$(sed -n '2p' .claude/rules/testing.md)" 'paths: ["tests/**"]'
bash "$PR" emit "$ROOT/templates/project-rules/ci.md" .claude/rules/ci.md 2>/dev/null
check T12f-ci-not-emitted-rc "$?" 1
check T12g-ci-not-written "$([ -e .claude/rules/ci.md ] && echo yes || echo no)" no
bash "$PR" emit "$ROOT/templates/project-rules/docker.md" .claude/rules/docker.md 2>/dev/null
check T12h-existing-target-rc "$?" 2
bash "$PR" check >/dev/null; check T12i-emitted-rules-pass-check "$?" 0
cd "$FIX" || exit 1
echo "PASS=$pass FAIL=$fail"
[ "$fail" -eq 0 ]
+1
View File
@@ -2,6 +2,7 @@
# Generated by /init-project or /onboard. Single source of truth for Claude in this repo.
# Global rules: ~/.claude/CLAUDE.md — this file extends or overrides them.
# Path-scoped rules: .claude/rules/<name>.md (paths: frontmatter), loaded on Read of a matching file.
---
+10
View File
@@ -0,0 +1,10 @@
---
paths: [".github/workflows/**", ".gitlab-ci.yml", ".circleci/**"]
---
# CI
<!-- Generated by /init-project or /onboard: loads on Read of a pipeline file. -->
<!-- TODO(/onboard STEP 3): jobs — lint, test, build, deploy; which run on PR vs main; required checks. -->
<!-- TODO(/onboard STEP 3): secrets — names only (never values), where they are set. -->
<!-- TODO(/onboard STEP 3): runtime versions pinned here must match the Stack section of CLAUDE.md. -->
+10
View File
@@ -0,0 +1,10 @@
---
paths: ["Dockerfile*", "docker-compose*", "compose*.y*ml", ".dockerignore"]
---
# Docker
<!-- Generated by /init-project or /onboard: loads on Read of a Docker file. -->
<!-- TODO(/onboard STEP 3): image — base image + version; multi-stage? what the final stage holds. -->
<!-- TODO(/onboard STEP 3): compose — services, volumes, ports, the env file it reads (.env, never a secret in the image). -->
<!-- TODO(/onboard STEP 3): commands — docker compose up --build / down -v, where they differ from the native run. -->
+10
View File
@@ -0,0 +1,10 @@
---
paths: ["tests/**", "test/**", "**/*.test.*", "**/*.spec.*", "**/conftest.py"]
---
# Testing conventions
<!-- Generated by /init-project or /onboard: loads on Read of a test file. -->
<!-- TODO(/onboard STEP 3): layout — where tests live, one file per module? naming (test_x.py / x.test.ts). -->
<!-- TODO(/onboard STEP 3): fixtures and factories — shared setup, what is mocked, what hits a real service. -->
<!-- TODO(/onboard STEP 3): rules — a bug fix ships its regression test; no sleep-based waits; coverage target if any. -->