From c69ce9ca8849b24620cf3049d3dcb2e672042389 Mon Sep 17 00:00:00 2001 From: bchanot Date: Thu, 12 Nov 2026 12:05:55 +0100 Subject: [PATCH] feat(doctrine): session start reads TODO and the digest, web rules deduped, graphify run from the repo Session start reads TODO.md and the memory digest, registries on demand. web-security keeps only its own rules and points to secure-by-default; the graphify rule names the CLAUDE.global.md append, Step 7 runs from $REPO. --- .claude/rules/graphify-vendored.md | 21 ++++++++++++--------- CLAUDE.global.md | 12 +++++++++--- install-plugins.sh | 8 +++++--- rules/web-security.md | 15 +++++---------- skills/capitalize/SKILL.md | 2 +- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.claude/rules/graphify-vendored.md b/.claude/rules/graphify-vendored.md index 7a92cff..d2df89b 100644 --- a/.claude/rules/graphify-vendored.md +++ b/.claude/rules/graphify-vendored.md @@ -5,23 +5,26 @@ paths: ["skills/graphify/**", "install-plugins.sh"] # Machine-owned: the vendored graphify skill `skills/graphify/SKILL.md`, `skills/graphify/references/` and -`.graphify_version` are written by `graphify claude install` -(`install-plugins.sh` STEP graphify), which lands in the repo because -`~/.claude/skills` is a symlink to `skills/`. They are gitignored: a +`.graphify_version` are written by `graphify install` (default platform +claude; `install-plugins.sh` STEP graphify), which lands in the repo +because `~/.claude/skills` is a symlink to `skills/`. They are gitignored: a `pipx upgrade graphifyy` used to dirty the tree and cost a `chore(graphify): sync vendored skill X -> Y` commit each time. Two graphify commands, easy to confuse, and only one restores the skill: - `graphify install --platform claude` copies SKILL.md + `references/` + - `.graphify_version` into `skills/graphify/`. Touches nothing else. - This is the recovery command. + `.graphify_version` into `skills/graphify/`, and appends a `# graphify` + block to `~/.claude/CLAUDE.md` = `CLAUDE.global.md` (graphifyy 0.9.67). + This is the recovery command; then delete that trailing block (one EOF + hunk in `git diff`), never check out the whole file. - `graphify claude install` writes the CLAUDE.md graphify section and the - `.claude/settings.json` PreToolUse hooks. It **rewrites both guarded - configs** (EVAL-020, verified again 2026-09-15), so revert them after. It does NOT copy - the skill. + `.claude/settings.json` PreToolUse hooks in the current directory. It + **rewrites both guarded configs** (EVAL-020, verified again 2026-09-15), + so revert them after. It does NOT copy the skill. `make plugin` runs both (`install-plugins.sh` STEP graphify) behind the -guarded-config EXIT trap, so a fresh clone is covered. +guarded-config EXIT trap, so a fresh clone is covered; `install-plugins.sh` +runs the second from `$REPO`, whatever the caller's cwd. Trade-off accepted: an upstream release can now change the skill's prompt with no diff to review. `skills/graphify/test-prompts.json` is hand-written diff --git a/CLAUDE.global.md b/CLAUDE.global.md index 6f6cc2d..c1975c6 100644 --- a/CLAUDE.global.md +++ b/CLAUDE.global.md @@ -50,9 +50,15 @@ code" wins. Repo-specific instructions override both. Hacky fix → rebuild clean, no over-engineering. ## Session start -1. Read `.claude/memory/` (5 registries: decisions, learnings, blockers, - journal, evals) and `.claude/tasks/TODO.md`. Apply before touching anything. -2. Either missing → create it first (templates: `~/.claude/templates/memory/`). +1. Read `.claude/tasks/TODO.md`. The banner's `memory digest` lists open + blockers and the last journal line: apply both before touching + anything; a `+N` line → read those entries in `blockers.md`. No + digest (foreign repo, memory mod off) → list the open blockers + yourself. +2. Read a registry (`.claude/memory/`: decisions, learnings, blockers, + journal, evals) when the task needs it; planning flows scan them per + `~/.claude/lib/analyze-before-plan.md`. +3. Either missing → create it first (templates: `~/.claude/templates/memory/`). ## Workflow - Confirm the approach only when real trade-offs exist (several valid diff --git a/install-plugins.sh b/install-plugins.sh index a732642..00cc32e 100644 --- a/install-plugins.sh +++ b/install-plugins.sh @@ -36,9 +36,11 @@ source "$REPO/lib/gstack-links.sh" # `# graphify` block to ~/.claude/CLAUDE.md = CLAUDE.global.md, which holds # the curated `## graphify` section: it matches the heading and appends, # it does not clobber) and `graphify claude install` (writes CLAUDE.md and -# .claude/settings.json in the caller's cwd, injecting aggressive MANDATORY +# .claude/settings.json in its own cwd, injecting aggressive MANDATORY # hooks). The EXIT trap restores the 4 $REPO files in GUARDED_CONFIGS -# (fully effective when run from $REPO, e.g. `make plugin`). `claude plugin +# (Step 7 runs `graphify claude install` from $REPO in a subshell, so the +# trap covers its CLAUDE.md and .claude/settings.json writes whatever the +# caller's cwd). `claude plugin # install` (Step 5) flips enable-states in settings.json. These 4 files are # maintained by hand + commit, never by the installer. Snapshot them now and # restore on exit so a run leaves them exactly as it found them. Pre-existing @@ -688,7 +690,7 @@ if command -v graphify &>/dev/null; then info "Running graphify install (dependencies)..." graphify install 2>/dev/null || { warn "graphify install failed — run manually"; _graphify_ok=0; } info "Configuring Claude Code integration..." - graphify claude install 2>/dev/null || { warn "graphify claude install failed — run manually"; _graphify_ok=0; } + (cd "$REPO" && graphify claude install) 2>/dev/null || warn "graphify claude install failed" # Success message gated on the real outcome (LRN-071 class: an # unconditional ok after `|| warn` lies when a step failed). if [ "$_graphify_ok" -eq 1 ]; then diff --git a/rules/web-security.md b/rules/web-security.md index abbf7a2..35e228d 100644 --- a/rules/web-security.md +++ b/rules/web-security.md @@ -4,18 +4,13 @@ paths: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.vue", "**/*.svelte", # Web app security — specifics -Extends the global Security section (input validation, parameterized -queries, secrets in env vars, AuthN/AuthZ, fail closed). If a request +Extends `~/.claude/rules/secure-by-default.md` (always on). If a request breaks one of these rules, say so instead of doing it. -- No API key in code shipped to the browser. Env vars, server-side only. -- The service/admin key never reaches the client: publishable key only. - Row Level Security enabled on every table (Supabase/Postgres and kin). -- Authentication verified server-side, never only in the browser. - No IDOR: changing an id in a URL must never expose another user's data. Authorize object access on every request. -- Passwords hashed (bcrypt/argon2). Session cookies httpOnly + secure - + sameSite. -- API responses return only the fields the client needs. -- Login rate limiting, upload restrictions (type/size), forced HTTPS, - security headers. +- Session cookies httpOnly + secure + sameSite. +- Uploads restricted by type and size. +- HTTPS forced. +- Security headers set. diff --git a/skills/capitalize/SKILL.md b/skills/capitalize/SKILL.md index 4004510..7b0e0d1 100644 --- a/skills/capitalize/SKILL.md +++ b/skills/capitalize/SKILL.md @@ -372,7 +372,7 @@ CAPITALIZE COMPLETE — () Then the closing line — pick by the STEP 5C persist result (`` = `Context flushed` for pre-wipe, `Session closed` for ritual): -- **auto-persisted (push mode `auto`, finish rc 0 AND `ahead` = 0)** → `✅ + persisted to origin/develop (). Next session: read .claude/memory/ at startup.` +- **auto-persisted (push mode `auto`, finish rc 0 AND `ahead` = 0)** → `✅ + persisted to origin/develop (). Next session: TODO.md and the startup digest (open blockers, last journal line).` On the `--no-push` path ONLY read TWO facts first, each its own Bash call: `bash "$HOME/.claude/lib/gitflow.sh" push-mode` and `git rev-list --count origin/chore/..chore/ 2>/dev/null || echo unknown` (`branch_ahead`). `` below is the verb's word. The WORKING-branch and rc 3 paths have no `chore/` and never use the mode.