Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
| `kit triage all <target>` | Auto-detect + run all checks. |
| `kit triage tools` | List installed security tools. |
| `kit triage check-deps` | Pre-commit gate: fail if staged deps lack triage entries. |
| `kit triage check-skills` | Pre-commit gate: fail if staged skills lack a `--deep` triage entry. |

## Packages + plugins

Expand Down
3 changes: 2 additions & 1 deletion docs/ENFORCEMENT_AND_AUDIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Deterministic, fail-closed, zero-LLM:
- **PreToolUse gates** — `gate-bash`, `gate-env` block un-triaged installs and plaintext-secret
writes *before* they land.
- **Capture-time gates** — the memory write-gate (G1), install-gate, slopsquat scoring (G4).
- **Commit/CI chokepoints** — `kit triage check-deps` (pre-commit), branch-protected checks.
- **Commit/CI chokepoints** — `kit triage check-deps` + `kit triage check-skills` (pre-commit,
wired by `kit setup --recommended`), branch-protected checks.
- **`warn → enforce` ramp** — a new gate warns first, then fails once enforced.

This is the "gravitation": you *can't* do X. It shapes **how** software gets built.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export async function cmdSetup(): Promise<boolean> {
recommended = profile.recommended;
} else {
recommended = await promptConfirm(
`Use the recommended profile? Wires cross-harness memory hooks (in ~/.claude) + git secret-scan${config.context ? " + context-check" : ""} gates after the core steps. [Y/n] `,
`Use the recommended profile? Wires cross-harness memory hooks (in ~/.claude) + git secret-scan + triage${config.context ? " + context-check" : ""} gates after the core steps. [Y/n] `,
10000,
profile.recommended,
);
Expand Down
6 changes: 4 additions & 2 deletions src/recommended.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ describe("applyRecommendedHardening", () => {
return mkdtempSync(join(tmp, "git-")) + "/.git";
}

it("wires memory hooks + a pre-commit secret-scan, and a pre-push when context is declared", async () => {
it("wires memory hooks + a pre-commit secret-scan + triage gates, and a pre-push when context is declared", async () => {
const g = gitDir();
const r = await applyRecommendedHardening({ context: { git: { email: "x@y.z" } } }, g);

// 3 memory hooks (UserPromptSubmit/SessionEnd/SessionStart).
assert.equal(r.memory.added.length, 3);

// pre-commit secret-scan gate.
// pre-commit secret-scan + triage gates (deps + skills).
const pc = readFileSync(join(g, "hooks", "pre-commit"), "utf-8");
assert.ok(pc.includes("security scan-staged"), "pre-commit runs security scan-staged");
assert.ok(pc.includes("triage check-deps"), "pre-commit runs the dep triage gate");
assert.ok(pc.includes("triage check-skills"), "pre-commit runs the skill triage gate");

// pre-push context-check gate (context was declared).
assert.ok(existsSync(join(g, "hooks", "pre-push")), "pre-push installed when context declared");
Expand Down
15 changes: 13 additions & 2 deletions src/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ function kitInvocation(): string {
/**
* The opinionated "recommended" hardening layered on top of `kit setup`:
* - cross-harness memory capture (the Claude Code hooks)
* - a pre-commit secret-scan gate
* - a pre-commit gate: secret-scan + triage gates for newly-added deps and staged skills
* - a pre-push context-check gate (only when `[context]` is declared)
*
* The triage gates (`kit triage check-deps` / `check-skills`) were always meant to run at
* commit time — they're the fail-closed chokepoint that refuses staged deps/skills lacking a
* recent triage. Wiring them into the recommended pre-commit turns the documented gates into
* enforced ones. Both are cheap no-ops when nothing relevant is staged.
*
* Each piece is idempotent and uses the already-hardened installers
* (absolute-path memory hooks; hooksPath-aware, no-clobber git hooks). It
* touches GLOBAL `~/.claude` (memory hooks) and the repo's git hooks, so the
Expand All @@ -37,7 +42,13 @@ export async function applyRecommendedHardening(
const memory = installMemoryHooks();

const kit = kitInvocation();
const hookConfig: HooksConfig = { "pre-commit": [`${kit} security scan-staged`] };
const hookConfig: HooksConfig = {
"pre-commit": [
`${kit} security scan-staged`,
`${kit} triage check-deps`,
`${kit} triage check-skills`,
],
};
// The context-check gate only makes sense once a context is declared.
if (config.context) {
hookConfig["pre-push"] = [`${kit} context check`];
Expand Down
Loading