Skip to content

feat(skills): retire safety-guard and apply the six context-engineering rules - #293

Open
naimkatiman wants to merge 9 commits into
mainfrom
chore/six-rules-context-engineering
Open

feat(skills): retire safety-guard and apply the six context-engineering rules#293
naimkatiman wants to merge 9 commits into
mainfrom
chore/six-rules-context-engineering

Conversation

@naimkatiman

Copy link
Copy Markdown
Owner

Applies the six context-engineering rules to this repo. The trigger was the operator's read of ~/.claude/usage-data/report-2026-08-07-231106.html (485 messages across 151 sessions, 2026-06-23 → 2026-08-07): "we use too much safety-guard skill."

The report's "Primary Friction Types" are almost entirely guard friction, not model error — Permission Denied 19, Tool Permission Blocked 17, Tool Permission Blocks 15, Permission Blocked 10, Tool Limitation 8, Tool Blocked By Guard 7 — with "gateguard intercepted the initial Write in 10+ sessions."

The core finding

skills/safety-guard.md was 78 lines claiming a runtime gate, a /safety-guard slash command, and a ~/.claude/safety-guard.log writer. None of the three ever shipped. Line 71 of the same file admitted enforcement was prose-only, contradicting its own frontmatter. skills/gateguard.md:191 compounded it by advertising the pair as "Runtime safety checks (complementary, not overlapping)" — false in both directions.

All three of its modes were already enforced for real by hooks/gateguard.mjs:

Retired mode What actually enforces it
Careful Destructive Bash Gate — superset of the watch list, blocks rather than warns
Freeze CI_GATEGUARD_TARGET_LOCK=block — canonicalizes the target against the project root, before the fact gate and independent of clearance
Guard Both, composed

Retirement was approved by the operator, superseding the "keep pending a separate decision" holds in docs/plans/2026-06-18-model-forward-retirement-candidates.md and docs/audits/2026-06-10-model-forward-audit.md. It is the call skills/model-forward.md:28 and :31 already prescribe.

Commits — one concern each

Commit Rule Change
838449a Plan doc
28fb7a0 1 — judgment over rules Retire safety-guard; migration map into gateguard; bundle 28 → 27
653078e 3 + 5 — progressive disclosure, automatic memory CLAUDE.md 101 → 74 lines; ledgers to docs/past-mistakes.md + docs/deferred.md; Past Mistakes pointer names recall as the first lookup
5931e89 4 — simpler tool descriptions Two overweight MCP descriptions trimmed; 2,979 → 2,573 chars (avg 157 → 135)
cffb3de 2 + 6 — design interfaces, richer references Generated docs/skill-catalog.html with an Enforcement column
82b9721 Plan doc updated to match shipped code

The structural fix

docs/skill-catalog.html is generated from skills/*.md frontmatter plus the live hooks/ and commands/ inventory. Every skill renders hook, command, or prosederived from the shipped file set, never from the skill's own prose. The mapping fails closed: a skill absent from HOOK_BY_SKILL degrades to command or prose, never to hook. A markdown row had nowhere to state what backs a skill, which is why prose-only scaffolding could advertise a runtime gate for months.

Current bundle: 6 hook, 13 command, 8 prose. Added to verify:generated so it cannot drift.

Verification

Gate Baseline 188d1e4 This branch
npm run verify:all 16 invariants + typecheck, exit 0 16 invariants + typecheck, exit 0
npm run verify:generated exit 0 exit 0 (now also covers docs/skill-catalog.html)
npm test 1116 tests, 1112 pass, 4 fail 1138 tests, 1138 pass, 0 fail, exit 0

The 4 baseline failures were test/hook.test.mjs (observe.sh) at 3.3–5.0s wall clock under the full parallel run on a loaded Windows host — the suite passed 15/15 in isolation on the same commit, and all passed on the final run once the host quieted. Environmental, not caused by this branch; recorded in docs/past-mistakes.md.

Both CI-pinned derived counts moved together: bundle 28 → 27 across the 5 manifest surfaces + the landing stat block, and the prose breakdown to 1 core + 1 featured + 6 tier-1 + 16 tier-2 + 3 always-bundled with next-ordinal 29th → 28th.

Scope notes

  • 28fb7a0 touches 36 files, above the 15-file guideline. Deliberate and not splittable: both count invariants and the mirror check fail on any partial application, so a split leaves CI red on the intermediate commit. ~18 are hand-edited source; the rest is generated output, which the guideline exempts.
  • Not touched: token-budget-advisor, strategic-compact, handoff, superpowers retirement decisions — separate operator calls, tracked in docs/deferred.md.
  • Not touched: gateguard's runtime behaviour. The measured friction is real, but loosening a hook with a +2.25 quality delta is a distinct evidence-gated decision, not a side effect of a docs pass.

Plan: docs/plans/2026-08-07-six-rules-context-engineering.md

Naim Katiman added 9 commits August 7, 2026 23:25
…ety-guard, route CLAUDE.md, thin the tool surface

Cites operator usage report 2026-08-07 (485 msgs/151 sessions) and skills/model-forward.md:28+31. Supersedes the safety-guard hold in docs/plans/2026-06-18-model-forward-retirement-candidates.md with explicit operator approval.
…y one enforcing surface

safety-guard was a prose-only tier-2 skill claiming a runtime gate, a slash command, and a log file — none of which ever shipped. All three of its modes are already enforced by hooks/gateguard.mjs: Careful by the Destructive Bash Gate, Freeze by CI_GATEGUARD_TARGET_LOCK=block, Guard by both composed. gateguard.md also claimed the two were 'complementary, not overlapping', which was false in both directions.

Bundle 28 -> 27 skills (16 tier-2). Adds a migration table to gateguard, drops the skill and its generated mirror, and updates every prose reference plus both CI-pinned derived counts. Plan: docs/plans/2026-08-07-six-rules-context-engineering.md
… ledgers

Past Mistakes (7 rows) and Deferred (10 findings) moved to docs/past-mistakes.md and docs/deferred.md; CLAUDE.md keeps a two-line pointer to each. 101 -> 74 lines with no content lost. The Past Mistakes pointer names recall as the first lookup — the observation log finds matching failures without curation; the doc is the curated subset. Adds the 2026-08-07 safety-guard entry. Plan: docs/plans/2026-08-07-six-rules-context-engineering.md
…aller cannot infer

ci_gateguard_clear 409 -> 219 chars and ci_distill_from_workflow 475 -> 250. Both restated material the model already has: the gate's fact list is printed verbatim in the hook's own block reason and again in skills/gateguard.md, and the workflow-recipe rationale was elaboration, not a decision input. Kept the two facts a caller cannot infer — path canonicalization, and draft-not-applied. 19 tool descriptions 2,979 -> 2,573 chars (avg 157 -> 135). Plan: docs/plans/2026-08-07-six-rules-context-engineering.md
…omes from shipped files, not prose

Adds src/lib/skill-catalog.mts and wires it into the manifest generator, so docs/skill-catalog.html is derived from skills/*.md frontmatter plus the actual hooks/ and commands/ inventory. Every skill renders hook, command, or prose; the mapping fails closed, so a skill missing from HOOK_BY_SKILL under-claims rather than over-claims. Current bundle: 6 hook, 13 command, 8 prose.

This is the structural fix for the safety-guard class of defect — a markdown row has nowhere to state what backs a skill, so prose-only scaffolding could advertise a runtime gate indefinitely. docs/skill-catalog.html joins verify:generated so it cannot drift. 22 new tests. Plan: docs/plans/2026-08-07-six-rules-context-engineering.md
…ed result

Freeze Mode needed no porting — CI_GATEGUARD_TARGET_LOCK already implemented it, so a migration map shipped instead of a ported section. The HTML catalog shipped generated + verify:generated-guarded rather than hand-authored. Adds the before/after gate table, including the 4 environmental baseline test failures that were not caused by this branch.
… catalog in CI

lib/skill-catalog.mjs was committed 100644 while the build chmods lib/*.mjs to 755, so Linux CI saw a mode-only drift and verify:generated failed. Windows core.filemode hides this locally. Audited every .mjs in the chmod'd directories — this was the only one.

Both workflows hardcode their own path list rather than calling npm run verify:generated, so the package.json change in cffb3de never reached CI. Added docs/skill-catalog.html to ci.yml and release.yml so the catalog is actually guarded against drift.
… retirement

main added the tier-1 ship skill (28 -> 29) and cut v3.23.0 while this branch sat open, so every count-bearing surface conflicted. Resolved by taking main's version of each conflicted file and re-applying the retirement on top: bundle is now 1 core + 1 featured + 7 tier-1 + 16 tier-2 + 3 always-bundled = 28 skills, on main's 3.23.0 base.

verify:all 16/16 green; npm test 1159/1159 pass. Plan: docs/plans/2026-08-07-six-rules-context-engineering.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant