@manukyalo/scopelock 2.2.0 → 3.0.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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # scopelock
1
+ # scopelock v3.0
2
2
 
3
3
  **Anti-hallucination scope locking for AI coding agents.**
4
4
 
@@ -12,86 +12,101 @@ npm install -g @manukyalo/scopelock
12
12
 
13
13
  ## Features
14
14
 
15
- - **File-level locks**: Run `scopelock lock src/auth.ts` to make the file read-only for agents.
16
- - **Function-level locks**: Don't want to lock the whole file? Lock specific AST functions so agents can only edit adjacent code.
17
- - **Dependency Lockdown**: Zero-trust dependency management. Automatically locks `package.json` and other dependency manifests on init to prevent silent dependency drift.
15
+ - **File & Function Locks**: Run `scopelock lock src/auth.ts` or `scopelock lock src/auth.ts:validateToken` to make code read-only for agents.
16
+ - **Production Path Locks (Seal)**: Use `scopelock seal` for critical paths like billing. Agents cannot override this; it requires explicit human sign-off via `scopelock unseal --human-approved=<ticket>`.
17
+ - **Blast Radius Map**: Prevent scope creep *before* it happens. Run `scopelock impact <file>` to see every file that imports a target file before you touch it.
18
+ - **Dependency Lockdown**: Zero-trust dependency management. Automatically locks `package.json` on init to prevent silent dependency drift.
18
19
  - **Secret Sentinel**: A hard-blocking pre-commit scanner that physically prevents agents from committing AWS keys, Stripe tokens, or `.env` leaks.
19
- - **Zero dependencies**: Written in pure Node.js. Install it anywhere without bloating your `node_modules`.
20
+ - **Test Coverage Gate**: Run `scopelock guard --tests` to block any source code changes that aren't accompanied by tests.
21
+ - **Rollback Snapshots**: Run `scopelock save` before an agent starts working, and `scopelock restore` to obliterate any rogue changes instantly.
20
22
 
21
23
  ---
22
24
 
23
25
  ## Commands
24
26
 
25
27
  ```bash
26
- scopelock init Scan repo and generate .scopelock.json
27
- scopelock lock <file>[:<func>] [reason] Lock a file or a specific function
28
- scopelock unlock <file>[:<func>] <reason> Unlock (reason is mandatory)
29
- scopelock allow-secret <file> <reason> Bypass Secret Sentinel for a specific file
30
- scopelock context [task] Generate AI context block for a task
31
- scopelock check Check git diff for scope violations and secret leaks
32
- scopelock status Show manifest summary
28
+ scopelock init Scan repo and generate .scopelock.json
29
+ scopelock lock <file>[:<func>] [reason] Lock a file or a specific function
30
+ scopelock unlock <file>[:<func>] <reason> Unlock (reason is mandatory)
31
+ scopelock seal <file> <reason> Permanent production-path lock (no override)
32
+ scopelock unseal <file> --human-approved=<ticket> <reason> Release a seal
33
+ scopelock impact <file> Show all files that import this file
34
+ scopelock trust <file> <reason> Bypass Secret Sentinel for a specific file
35
+ scopelock save Auto-snapshot repo state before an agent session
36
+ scopelock restore Rollback to the last snapshot
37
+ scopelock context [task] Generate AI context block for a task
38
+ scopelock guard [--tests] Check git diff for violations and secret leaks
39
+ scopelock status Show manifest summary
33
40
  ```
34
41
 
35
- ### `scopelock init`
36
- Scan the repo and generate `.scopelock.json`. Automatically ignores `node_modules`, `.git`, `.next`, `dist`, `build`, `out`, `coverage`, and other build artifacts.
37
-
38
- ### `scopelock lock <file>[:<function>] [reason]`
39
- Lock a whole file or a specific named function.
42
+ ### `scopelock lock` & `unlock`
43
+ Lock a whole file or a specific named function. Unlock requires a reason that gets logged to history.
40
44
 
41
45
  ```bash
42
- # Lock a whole file
43
46
  scopelock lock src/lib/supabase.ts "production client — stable"
44
-
45
- # Lock a specific function (validates it exists before locking)
46
47
  scopelock lock src/auth/token.ts:validateToken "tested — do not touch"
48
+ scopelock unlock src/auth/token.ts:validateToken "fixing JWT expiry edge case"
47
49
  ```
48
50
 
49
- ### `scopelock unlock <file>[:<function>] <reason>`
50
- Unlock a file or function. Reason is mandatory and logged.
51
+ ### `scopelock seal` & `unseal`
52
+ For files that should *never* be touched without human oversight (e.g., `/billing`, `/migrations`). Seals cannot be removed by `unlock`.
51
53
 
52
54
  ```bash
53
- scopelock unlock src/auth/token.ts:validateToken "fixing JWT expiry edge case"
55
+ scopelock seal src/billing/stripe.ts "core billing logic"
56
+ scopelock unseal src/billing/stripe.ts --human-approved=PR-123 "updating webhook"
54
57
  ```
55
58
 
56
- ### `scopelock allow-secret <file> <reason>`
57
- Bypass the Secret Sentinel hard-block for a specific file (e.g., when intentionally committing a mock test key).
59
+ ### `scopelock impact`
60
+ Before making a change, see the blast radius. Outputs a list of all files in the repository that import the target file.
58
61
 
59
62
  ```bash
60
- scopelock allow-secret test/run.js "this is a mock stripe key for testing"
63
+ scopelock impact src/utils/auth.ts
61
64
  ```
62
65
 
63
- ### `scopelock check`
64
- Two-tier scope violation check against `git diff HEAD`. Exits non-zero on violations or secret leaks. Wire this up as a `pre-commit` hook.
66
+ ### `scopelock guard`
67
+ Two-tier scope violation check against `git diff HEAD`. Exits non-zero on violations or secret leaks. Wire this up as a `pre-commit` hook. Add `--tests` to strictly enforce test coverage for any changed logic.
65
68
 
66
69
  ```bash
67
- scopelock check
70
+ scopelock guard
71
+ scopelock guard --tests
68
72
  ```
69
73
 
70
- ### `scopelock context [task]`
71
- Output a token-efficient AI context block with all locks clearly flagged.
74
+ ### `scopelock save` & `restore`
75
+ Never fear an agent hallucination destroying your workspace again. `save` stores a snapshot in git stash that survives hard resets. `restore` obliterates the working directory and cleanly reverts to the snapshot.
72
76
 
73
77
  ```bash
74
- scopelock context "Update the login page"
78
+ scopelock save
79
+ scopelock restore
75
80
  ```
81
+
82
+ ### `scopelock trust`
83
+ Bypass the Secret Sentinel hard-block for a specific file (e.g., when intentionally committing a mock test key).
84
+
85
+ ```bash
86
+ scopelock trust test/run.js "this is a mock stripe key for testing"
76
87
  ```
77
- [SCOPE CONTEXT]
78
- Task: Update the login page
79
88
 
80
- Status:
81
- 🔒 locked — 1 file(s)
82
- ✏️ active — 0 file(s)
83
- ⬜ unscoped — 14 file(s)
89
+ ### `scopelock context`
90
+ Output a token-efficient AI context block with all locks clearly flagged for the agent's system prompt.
84
91
 
85
- Locked files:
86
- src/lib/supabase.ts
92
+ ```bash
93
+ scopelock context "Update the login page"
87
94
  ```
88
95
 
89
- ## Agent Skill
96
+ ## Agent Skills (Godmode)
97
+
98
+ `scopelock` ships with 7 native AI Agent Skills located in the `skills/` folder.
99
+ If you use an agent framework (like Antigravity or Cline) that supports Markdown skills, point it to these folders to automatically teach the agent how to use `scopelock` safely.
90
100
 
91
- `scopelock` includes a native Agent Skill.
92
- If you use an agent framework (like Antigravity or Cline) that supports Markdown skills, point it to `skills/scope-enforcement/SKILL.md` to automatically teach the agent how to use `scopelock` safely.
101
+ The skills map directly to features:
102
+ - `scope-enforcement`
103
+ - `dependency-lockdown`
104
+ - `secret-sentinel`
105
+ - `test-coverage-gate`
106
+ - `rollback-snapshot`
107
+ - `blast-radius`
108
+ - `production-path-lock`
93
109
 
94
110
  ## Data Model
95
111
  All state is stored in `.scopelock.json` at the root of your repo.
96
-
97
112
  The manifest is project state, not a personal config. Commit it so your whole team — and all their AI agents — share the same scope boundaries.
package/bin/scopelock.js CHANGED
@@ -17,6 +17,7 @@ const { execSync } = require('child_process');
17
17
  const manifest = require('../src/manifest');
18
18
  const context = require('../src/context');
19
19
  const git = require('../src/git');
20
+ const blast = require('../src/blast');
20
21
 
21
22
  const [,, command, ...args] = process.argv;
22
23
 
@@ -54,26 +55,60 @@ switch (command) {
54
55
  break;
55
56
  }
56
57
 
57
- case 'check':
58
- git.check(args);
58
+ case 'guard':
59
+ git.guard(args);
59
60
  break;
60
61
 
61
62
  case 'status':
62
63
  manifest.status();
63
64
  break;
64
65
 
65
- case 'allow-secret': {
66
+ case 'impact': {
67
+ const target = args[0];
68
+ if (!target) {
69
+ console.error('Usage: scopelock impact <file>');
70
+ process.exit(1);
71
+ }
72
+ blast.printBlastRadius(target);
73
+ break;
74
+ }
75
+
76
+ case 'seal': {
77
+ const target = args[0];
78
+ const reason = args.slice(1).join(' ') || 'production path — seal applied';
79
+ if (!target) {
80
+ console.error('Usage: scopelock seal <file> <reason>');
81
+ process.exit(1);
82
+ }
83
+ manifest.seal(target, reason);
84
+ break;
85
+ }
86
+
87
+ case 'unseal': {
88
+ const target = args[0];
89
+ const ticketArg = args.find(a => a.startsWith('--human-approved='));
90
+ const ticket = ticketArg ? ticketArg.replace('--human-approved=', '') : null;
91
+ const reason = args.filter(a => !a.startsWith('--')).slice(1).join(' ');
92
+ if (!target || !ticket || !reason) {
93
+ console.error('Usage: scopelock unseal <file> --human-approved=<ticket> <reason>');
94
+ process.exit(1);
95
+ }
96
+ manifest.unseal(target, ticket, reason);
97
+ break;
98
+ }
99
+
100
+ case 'trust': {
66
101
  const target = args[0];
67
102
  const reason = args.slice(1).join(' ');
68
103
  if (!target || !reason) {
69
- console.error('Usage: scopelock allow-secret <file> <reason>');
104
+ console.error('Usage: scopelock trust <file> <reason>');
70
105
  process.exit(1);
71
106
  }
72
- manifest.allowSecret(target, reason);
107
+ manifest.trust(target, reason);
73
108
  break;
74
109
  }
75
110
 
76
- case 'snapshot': {
111
+ case 'save': {
77
112
  try {
78
113
  const ts = new Date().toISOString().replace(/[:.]/g, '-');
79
114
  const manifestObj = manifest.getManifest();
@@ -94,7 +129,7 @@ switch (command) {
94
129
  }
95
130
 
96
131
  manifest.saveManifest(manifestObj);
97
- console.log(`✅ Snapshot created. Run 'scopelock revert' to obliterate agent changes and restore this state.`);
132
+ console.log(`✅ Snapshot created. Run 'scopelock restore' to obliterate agent changes and restore this state.`);
98
133
  } catch (e) {
99
134
  console.error('Failed to create snapshot.', e.stderr || e.message);
100
135
  process.exit(1);
@@ -102,11 +137,11 @@ switch (command) {
102
137
  break;
103
138
  }
104
139
 
105
- case 'revert': {
140
+ case 'restore': {
106
141
  try {
107
142
  const manifestObj = manifest.getManifest();
108
143
  if (!manifestObj.lastSnapshot) {
109
- console.error('❌ No snapshot found. Run `scopelock snapshot` first.');
144
+ console.error('❌ No snapshot found. Run `scopelock save` first.');
110
145
  process.exit(1);
111
146
  }
112
147
  console.log(`Obliterating agent mess...`);
@@ -136,15 +171,18 @@ switch (command) {
136
171
  scopelock — Anti-hallucination scope locking for AI coding agents.
137
172
 
138
173
  Usage:
139
- scopelock init Scan repo and generate .scopelock.json
140
- scopelock lock <file>[:<func>] [reason] Lock a file or a specific function
141
- scopelock unlock <file>[:<func>] <reason> Unlock (reason is mandatory)
142
- scopelock allow-secret <file> <reason> Bypass Secret Sentinel for a specific file
143
- scopelock context [task] Generate AI context block for a task
144
- scopelock snapshot Auto-snapshot repo state before an agent session
145
- scopelock revert Rollback to the last snapshot
146
- scopelock check [--require-tests] Check git diff for violations and test coverage
147
- scopelock status Show manifest summary
174
+ scopelock init Scan repo and generate .scopelock.json
175
+ scopelock lock <file>[:<func>] [reason] Lock a file or a specific function
176
+ scopelock unlock <file>[:<func>] <reason> Unlock (reason is mandatory)
177
+ scopelock seal <file> <reason> Permanent production-path lock (no override)
178
+ scopelock unseal <file> --human-approved=<ticket> <reason> Release a seal
179
+ scopelock impact <file> Show all files that import this file
180
+ scopelock trust <file> <reason> Bypass Secret Sentinel for a specific file
181
+ scopelock save Auto-snapshot repo state before an agent session
182
+ scopelock restore Rollback to the last snapshot
183
+ scopelock context [task] Generate AI context block for a task
184
+ scopelock guard [--tests] Check git diff for violations and secret leaks
185
+ scopelock status Show manifest summary
148
186
 
149
187
 
150
188
  Examples:
@@ -152,7 +190,7 @@ Examples:
152
190
  scopelock lock src/auth.ts:validateToken "stable — do not touch"
153
191
  scopelock unlock src/auth.ts:validateToken "need to fix JWT expiry bug"
154
192
  scopelock context "Fix the broken checkout flow"
155
- scopelock check
193
+ scopelock guard
156
194
  `);
157
195
  process.exit(1);
158
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manukyalo/scopelock",
3
- "version": "2.2.0",
3
+ "version": "3.0.0",
4
4
  "description": "Anti-hallucination scope locking for AI coding agents.",
5
5
  "main": "bin/scopelock.js",
6
6
  "bin": {
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: blast-radius-map
3
+ description: "Godmode Skill: Before modifying any file, run 'scopelock impact <file>' to see every other file that imports it. Prevents scope creep by making the full impact of a change visible BEFORE the agent writes a single line."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ An AI agent can't know what it doesn't know. If it modifies `src/utils/auth.ts` without understanding that 14 other files import it, it has no idea if the function signature change it's making will cascade into 14 broken components.
9
+
10
+ This skill instructs the agent to **check before it touches**, not after.
11
+
12
+ ## Agent Protocol
13
+
14
+ ### MANDATORY: Before editing any file
15
+
16
+ 1. Run the blast radius check first:
17
+ ```bash
18
+ scopelock impact src/utils/auth.ts
19
+ ```
20
+
21
+ 2. Read the output:
22
+ ```
23
+ 💥 Blast Radius: src/utils/auth.ts
24
+
25
+ 7 file(s) directly import this file:
26
+
27
+ → src/pages/login.tsx
28
+ → src/pages/register.tsx
29
+ → src/api/session.ts
30
+ → src/middleware.ts
31
+ → src/hooks/useUser.ts
32
+ → test/auth.test.ts
33
+ → test/session.test.ts
34
+
35
+ ⚠️ Modifying 'src/utils/auth.ts' may impact all 7 of the above file(s).
36
+ ```
37
+
38
+ 3. **Assess the risk** based on what you see:
39
+ - **0 dependents** → safe to modify freely.
40
+ - **1–5 dependents** → proceed carefully, check each dependent after your change.
41
+ - **6+ dependents** → this is a high-blast-radius file. Consider locking it and building a new abstraction instead of modifying it directly.
42
+
43
+ 4. If you decide to proceed, lock all other files first:
44
+ ```bash
45
+ scopelock lock src/pages/login.tsx "blast radius protection"
46
+ scopelock lock src/middleware.ts "blast radius protection"
47
+ # ... etc
48
+ ```
49
+
50
+ 5. Make your change to the target file only.
51
+
52
+ 6. Run `scopelock guard` to verify no locked files were touched.
53
+
54
+ ## Why this exists
55
+
56
+ The most expensive bugs come from changes that seemed small but weren't. This skill makes the full impact of every change explicit before the agent commits to it.
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: dependency-lockdown
3
+ description: "Godmode Skill: Prevents AI agents from silently adding or upgrading npm/pip/cargo packages. Dependency manifest files (package.json, requirements.txt, etc.) are automatically locked by scopelock on init. Any diff touching these files will fail scopelock guard until explicitly unlocked with a reason."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Dependency drift is one of the most common and expensive agent mistakes. An agent trying to fix one bug will silently add 12 packages, bloat the bundle, and introduce unknown vulnerabilities. This skill makes that impossible.
9
+
10
+ ## How it Works
11
+
12
+ On `scopelock init`, the following files are **automatically locked** without any manual action required:
13
+ - `package.json`, `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`
14
+ - `requirements.txt`, `Pipfile`, `Pipfile.lock`, `poetry.lock`
15
+ - `Cargo.toml`, `Cargo.lock`, `go.mod`, `go.sum`
16
+
17
+ ## Agent Protocol
18
+
19
+ ### When you need to add a dependency:
20
+ 1. You MUST explicitly unlock the manifest first with a clear reason:
21
+ ```bash
22
+ scopelock unlock package.json "adding zod for runtime validation of API responses"
23
+ ```
24
+ 2. Make your change (add the dependency to the manifest).
25
+ 3. Run `scopelock guard` to confirm the change is authorized.
26
+ 4. Re-lock the manifest immediately after:
27
+ ```bash
28
+ scopelock lock package.json "dependencies updated and reviewed"
29
+ ```
30
+
31
+ ### When you do NOT need a new dependency:
32
+ - If you find yourself reaching for a new package, stop and ask: can this be solved with a built-in or existing dependency?
33
+ - The lock exists to force that question before the decision is made.
34
+
35
+ ## Why this exists
36
+
37
+ Agents never "just need one package." Every dependency is a long-term maintenance cost, a security surface, and a potential supply chain attack vector. This skill enforces that every dependency addition is a deliberate, logged, human-approved decision.
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: production-path-lock
3
+ description: "Godmode Skill: A permanent, override-resistant lock for critical production paths like /auth, /billing, /migrations. Regular 'scopelock unlock' cannot bypass it. Requires a second human's explicit sign-off via 'scopelock unseal' with a ticket."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Some files must never be touched by an AI agent without explicit human sign-off. Your `/auth` logic, billing handlers, and database migration files are not negotiable. A `seal` makes this a physical constraint, not a policy.
9
+
10
+ A sealed file cannot be overridden by `scopelock unlock`. The agent must stop, escalate to a human, and provide a traceable ticket before any modification is allowed.
11
+
12
+ ## Recommended Files to Seal on Every Project
13
+
14
+ ```bash
15
+ # Authentication
16
+ scopelock seal src/auth/token.ts "core auth — requires senior review"
17
+ scopelock seal src/middleware/auth.ts "core auth — requires senior review"
18
+
19
+ # Billing & Payments
20
+ scopelock seal src/billing/stripe.ts "billing — requires finance team approval"
21
+ scopelock seal src/billing/webhooks.ts "billing — requires finance team approval"
22
+
23
+ # Database Migrations
24
+ scopelock seal migrations/ "schema changes — requires DBA review"
25
+
26
+ # Security-critical config
27
+ scopelock seal .env.production "production secrets — never touch"
28
+ ```
29
+
30
+ ## Agent Protocol
31
+
32
+ ### When you encounter a sealed file:
33
+ ```
34
+ ❌ 'src/auth/token.ts' is SEALED and cannot be unlocked with 'scopelock unlock'.
35
+ This path is a protected production route.
36
+ Use: scopelock unseal src/auth/token.ts --human-approved=<ticket> <reason>
37
+ ```
38
+
39
+ 1. **STOP.** Do not attempt to work around the lock.
40
+ 2. **Escalate.** Tell the human you cannot proceed without their explicit approval.
41
+ 3. **The human must run:**
42
+ ```bash
43
+ scopelock unseal src/auth/token.ts --human-approved=JIRA-123 "fixing JWT expiry bug approved in PR-456"
44
+ ```
45
+ 4. Only after you see the `UNSEALED` confirmation may you proceed.
46
+ 5. Re-seal the file immediately after your change is committed:
47
+ ```bash
48
+ scopelock seal src/auth/token.ts "re-locked after JWT fix — JIRA-123"
49
+ ```
50
+
51
+ ## The Audit Trail
52
+
53
+ Every `unseal` is permanently logged in `.scopelock.json` with:
54
+ - The timestamp
55
+ - The human-approved ticket number
56
+ - The full reason string
57
+
58
+ This creates a traceable, auditable record of every time a production path was modified — essential for SOC2, GDPR, and any compliance review.
59
+
60
+ ## Why this exists
61
+
62
+ `locked` is a request. `sealed` is a wall. Some files need a wall.
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: rollback-snapshot
3
+ description: "Godmode Skill: Creates a one-command safety net before every agent session. If the agent goes rogue, a single command obliterates all changes and perfectly restores the repository to its pre-session state."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Before you let an agent loose on a codebase, you need a guaranteed escape hatch. `scopelock save` creates that escape hatch using git's native stash mechanism. It is instant, requires no external tools, and can restore the repo to its exact pre-session state in under one second.
9
+
10
+ ## How Storage Works
11
+
12
+ - The snapshot is stored in **git's local stash** (`.git/refs/stash`) — it never leaves your machine and is never pushed to GitHub.
13
+ - The `.scopelock.json` manifest stores a pointer (`lastSnapshot: "dirty" | "clean"`) so `scopelock restore` knows what to restore.
14
+ - If you clone the repo on a new machine, the snapshot is gone — this is correct. Snapshots are session-scoped, not repository-scoped.
15
+
16
+ ## Agent Protocol
17
+
18
+ ### At the start of EVERY agent session:
19
+ ```bash
20
+ scopelock save
21
+ ```
22
+ This is the first command you run, before writing a single line of code.
23
+
24
+ ### If the session goes well:
25
+ Simply commit your work normally. The stash will remain in git until git's garbage collection cleans it up automatically (default: 90 days).
26
+
27
+ ### If the agent goes rogue:
28
+ ```bash
29
+ scopelock restore
30
+ ```
31
+ This command:
32
+ 1. Runs `git reset --hard HEAD` — obliterates all tracked file changes.
33
+ 2. Runs `git clean -fd` — deletes all untracked files the agent created.
34
+ 3. Pops the stash — restores your working tree to the exact state at snapshot time.
35
+
36
+ ## When to Use
37
+
38
+ - Before any multi-file refactor.
39
+ - Before any session where the agent is given broad instructions like "fix all the TypeScript errors."
40
+ - Before any experiment where you are not 100% sure of the outcome.
41
+
42
+ ## Why this exists
43
+
44
+ `Ctrl+Z` doesn't work across a 45-minute agent session. This skill gives you a time machine.
@@ -10,7 +10,7 @@ AI coding agents default to the shortest path to a passing result — which freq
10
10
  This skill uses `scopelock` — a zero-dependency Node.js CLI — to enforce two tiers of scope protection:
11
11
 
12
12
  - **File-level:** An entire file is locked. No agent may touch it.
13
- - **Function-level:** A specific function within a file is locked. The file may be edited, but that function's body is off-limits. `scopelock check` detects if any changed line falls inside the locked function's boundaries.
13
+ - **Function-level:** A specific function within a file is locked. The file may be edited, but that function's body is off-limits. `scopelock guard` detects if any changed line falls inside the locked function's boundaries.
14
14
 
15
15
  The skill operates at three checkpoints: **Session Start**, **Pre-Commit**, and **Post-Task Review**.
16
16
 
@@ -64,7 +64,7 @@ scopelock lock src/auth/token.ts:validateToken "tested, do not touch"
64
64
 
65
65
  **Step 4: Run the scope check.**
66
66
  ```bash
67
- scopelock check
67
+ scopelock guard
68
68
  ```
69
69
 
70
70
  Two-tier enforcement:
@@ -87,7 +87,7 @@ git restore <file>
87
87
  *Genuinely required change:*
88
88
  ```bash
89
89
  scopelock unlock src/auth/token.ts:validateToken "fixing JWT expiry edge case"
90
- scopelock check # must pass before committing
90
+ scopelock guard # must pass before committing
91
91
  ```
92
92
 
93
93
  ---
@@ -108,7 +108,7 @@ scopelock lock src/auth/token.ts:validateToken "fixed and re-locked"
108
108
 
109
109
  ```bash
110
110
  echo '#!/bin/sh
111
- scopelock check' > .git/hooks/pre-commit
111
+ scopelock guard' > .git/hooks/pre-commit
112
112
  chmod +x .git/hooks/pre-commit
113
113
  ```
114
114
 
@@ -123,14 +123,14 @@ chmod +x .git/hooks/pre-commit
123
123
  | "The agent said it needed to modify that function." | Then re-evaluate scope, not the lock. If you can't write a specific reason, the modification isn't justified. |
124
124
  | "Function-level locking is overkill." | File-level locking doesn't stop an agent from rewriting a critical function inside a file marked `active`. |
125
125
  | "The parser didn't detect my function." | Use file-level locking instead. Flag the miss — it's a parser bug, not a reason to skip protection. |
126
- | "Running `scopelock check` slows my commit flow." | Under 300ms. The alternative is debugging a hallucinated refactor for hours. |
126
+ | "Running `scopelock guard` slows my commit flow." | Under 300ms. The alternative is debugging a hallucinated refactor for hours. |
127
127
  | ".scopelock.json shouldn't be committed." | Commit it. It's shared project state — your whole team and their agents benefit. |
128
128
 
129
129
  ---
130
130
 
131
131
  ## Red Flags
132
132
 
133
- - `scopelock check` reports violations in more than 2 files — significant scope drift.
133
+ - `scopelock guard` reports violations in more than 2 files — significant scope drift.
134
134
  - An unlock entry has a vague reason string (e.g., "fix", "update") — bypassed without thinking.
135
135
  - The agent proposes unlocking multiple files at once with one generic reason — batch rationalization.
136
136
  - A locked function is reported as `function-missing` after a diff — it was deleted or renamed.
@@ -144,7 +144,7 @@ A session is compliant when ALL of the following are true:
144
144
 
145
145
  - [ ] `.scopelock.json` exists and `scopelock status` shows the expected locks.
146
146
  - [ ] `scopelock context "<task>"` output was injected into the agent before any code was written.
147
- - [ ] `scopelock check` exits `0` before every commit in this session.
147
+ - [ ] `scopelock guard` exits `0` before every commit in this session.
148
148
  - [ ] Every `unlock` entry has a specific, task-justified reason string.
149
149
  - [ ] No diff contains modifications to locked files or lines inside locked function bodies that were not explicitly unlocked.
150
150
  - [ ] All modified files and functions have been reviewed for re-locking post-task.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: secret-sentinel
3
+ description: "Godmode Skill: Physically blocks AI agents from committing API keys, tokens, or .env leaks. scopelock guard scans every added line in the git diff for high-entropy secrets before the commit is allowed. This is a hard block — not a warning."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Leaked secrets are the number one cause of production security incidents caused by AI agents. An agent will hardcode an API key to "test something quickly" and forget to remove it. This skill prevents that from ever reaching the repo.
9
+
10
+ ## What Gets Blocked
11
+
12
+ The Secret Sentinel scans every newly added line for:
13
+ - **AWS Access Keys** (`AKIA...`)
14
+ - **Stripe Secret Keys** (`sk_live_...`, `sk_test_...`)
15
+ - **GitHub Tokens** (`ghp_...`, `ghs_...`)
16
+ - **Slack Tokens** (`xoxb-...`, `xoxs-...`)
17
+ - **Generic hardcoded secrets** (any `api_key = "..."`, `password = "..."`, `token = "..."` with a value 16+ chars long)
18
+
19
+ ## Agent Protocol
20
+
21
+ ### Before every commit:
22
+ ```bash
23
+ scopelock guard
24
+ ```
25
+ If a secret is detected, you will see:
26
+ ```
27
+ ❌ VIOLATION: SECRET LEAK [Stripe Secret Key] detected in 'src/api.ts' on line 42.
28
+ ```
29
+
30
+ ### How to resolve:
31
+ 1. **Remove the secret from the file** — use an environment variable instead:
32
+ ```ts
33
+ // WRONG — will be blocked
34
+ const key = "sk_live_1234abcdefgh";
35
+
36
+ // CORRECT — reads from environment
37
+ const key = process.env.STRIPE_SECRET_KEY;
38
+ ```
39
+ 2. Add the secret to `.env` (which should be in `.gitignore`).
40
+ 3. Add the variable name to `.env.example` so other developers know it exists.
41
+
42
+ ### Intentional exception (mock/test keys only):
43
+ If you are intentionally committing a **mock** key for testing purposes, a human must explicitly authorize it:
44
+ ```bash
45
+ scopelock trust test/fixtures/mock.ts "contains a mock stripe key for unit tests — not a real key"
46
+ ```
47
+ This bypass is logged permanently in `.scopelock.json` for audit purposes.
48
+
49
+ ## Why this exists
50
+
51
+ You cannot undo a leaked secret that was pushed to a public GitHub repo. This skill makes leaking a secret a physical impossibility, not a code review catch.
@@ -1,19 +1,19 @@
1
1
  ---
2
2
  name: test-coverage-gate
3
- description: "Godmode Skill: Forces the AI agent to write or update test files whenever it modifies application logic. Run 'scopelock check --require-tests' before committing to enforce this rule."
3
+ description: "Godmode Skill: Forces the AI agent to write or update test files whenever it modifies application logic. Run 'scopelock guard --tests' before committing to enforce this rule."
4
4
  ---
5
5
 
6
6
  ## Overview
7
7
 
8
8
  This skill teaches the agent how to navigate the `scopelock` Test Coverage Gate.
9
- When `--require-tests` is active, the CLI will hard-block any commit that modifies a source file (`.js`, `.ts`, `.py`, etc.) if a corresponding test file (`.test.ts`, `.spec.js`, `test/`) is not also modified in the same diff.
9
+ When `--tests` is active, the CLI will hard-block any commit that modifies a source file (`.js`, `.ts`, `.py`, etc.) if a corresponding test file (`.test.ts`, `.spec.js`, `test/`) is not also modified in the same diff.
10
10
 
11
11
  ## Agent Protocol
12
12
 
13
13
  1. **Before writing code**: If you are about to modify application logic, understand that your changes will be rejected unless you also provide test coverage.
14
14
  2. **Write the code**: Implement the requested feature or fix.
15
15
  3. **Write the test**: You *must* update the corresponding test file or create a new one. The file path must contain `.test.`, `.spec.`, or be inside a `test/` or `__tests__/` directory.
16
- 4. **Validation**: Run `scopelock check --require-tests` to mathematically verify your diff will pass the coverage gate.
16
+ 4. **Validation**: Run `scopelock guard --tests` to mathematically verify your diff will pass the coverage gate.
17
17
  5. **Ship**: Only after the test gate is passed are you allowed to commit or mark the task as complete.
18
18
 
19
19
  ## Why this exists