$npx -y skills add Rune-kit/rune --skill scope-guardDetects scope creep by quantifying drift percentage. Auto-triggered by L1 orchestrators when files exceed the original plan. Compares git changes against plan, classifies drift into 4 tiers: ON_TRACK, MINOR_DRIFT, SIGNIFICANT_DRIFT, OUT_OF_CONTROL.
| 1 | # scope-guard |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Passive scope monitor. Reads the original task plan, inspects current git diff to see what files have changed, and compares them against the planned scope. Flags any unplanned additions as scope creep with specific file-level detail. |
| 6 | |
| 7 | ## Called By (inbound) |
| 8 | |
| 9 | - `cook` (L1): Phase 6.6 scope drift detection when files touched > planned |
| 10 | - `team` (L1): after each parallel workstream completes, before merge |
| 11 | - `rescue` (L1): during safeguard phase to detect unplanned changes |
| 12 | - `plan` (L2): optional scope validation after plan acceptance |
| 13 | |
| 14 | ## Calls (outbound) |
| 15 | |
| 16 | None — pure L3 monitoring utility. |
| 17 | |
| 18 | ## Executable Instructions |
| 19 | |
| 20 | ### Step 1: Load Plan |
| 21 | |
| 22 | Read the original task/plan from one of these sources (check in order): |
| 23 | |
| 24 | 1. TodoWrite task list — read active todos as the planned scope |
| 25 | 2. `.rune/progress.md` — use `Read` on `D:\Project\.rune\progress.md` (or equivalent path) |
| 26 | 3. If neither exists, ask the calling skill to provide the plan as a text description |
| 27 | |
| 28 | Extract from the plan: |
| 29 | - List of files/directories expected to be changed |
| 30 | - List of features/tasks planned |
| 31 | - Any explicitly out-of-scope items mentioned |
| 32 | |
| 33 | ### Step 2: Assess Current Work |
| 34 | |
| 35 | Run `Bash` with git diff to see what has actually changed: |
| 36 | |
| 37 | ```bash |
| 38 | git diff --stat HEAD |
| 39 | ``` |
| 40 | |
| 41 | Also check staged changes: |
| 42 | |
| 43 | ```bash |
| 44 | git diff --stat --cached |
| 45 | ``` |
| 46 | |
| 47 | Parse the output to extract the list of changed files. |
| 48 | |
| 49 | ### Step 3: Compare |
| 50 | |
| 51 | For each changed file, determine if it is: |
| 52 | - **IN_SCOPE**: file matches a planned file/directory or is a natural dependency of planned work |
| 53 | - **OUT_OF_SCOPE**: file is not mentioned in the plan and is not a direct dependency |
| 54 | |
| 55 | Rules for "natural dependency" (counts as IN_SCOPE): |
| 56 | - Test files for planned source files |
| 57 | - Config files modified as a side-effect of adding a planned feature |
| 58 | - Lock files (package-lock.json, yarn.lock, Cargo.lock) — always IN_SCOPE |
| 59 | |
| 60 | Rules for OUT_OF_SCOPE (counts as creep): |
| 61 | - New features not mentioned in the plan |
| 62 | - Refactoring of files unrelated to the task |
| 63 | - New dependencies added without a planned feature requiring them |
| 64 | - Documentation files for unplanned features |
| 65 | |
| 66 | ### Step 4: Quantify Drift |
| 67 | |
| 68 | Compute **Drift Percentage** — the ratio of out-of-scope changes to total changes: |
| 69 | |
| 70 | ``` |
| 71 | drift_pct = (out_of_scope_files / total_files_changed) × 100 |
| 72 | ``` |
| 73 | |
| 74 | Classify drift into a 4-tier system: |
| 75 | |
| 76 | | Drift % | Level | Status | Action | |
| 77 | |---------|-------|--------|--------| |
| 78 | | **< 10%** | ON TRACK | `ON_TRACK` | No action needed. Proceed normally. | |
| 79 | | **10-25%** | MINOR DRIFT | `MINOR_DRIFT` | Flag out-of-scope files. Suggest trim or acknowledge as intentional. Continue. | |
| 80 | | **25-50%** | SIGNIFICANT DRIFT | `SIGNIFICANT_DRIFT` | **Pause recommended.** Present drift report to user. Re-scope before continuing. | |
| 81 | | **> 50%** | OUT OF CONTROL | `OUT_OF_CONTROL` | **Block.** More unplanned work than planned. Escalate to orchestrator. Require re-alignment before ANY further work. | |
| 82 | |
| 83 | **Edge case**: If total planned files = 0 (no plan loaded), use file count thresholds instead: |
| 84 | - 0 out-of-scope → ON_TRACK |
| 85 | - 1-2 out-of-scope → MINOR_DRIFT |
| 86 | - 3-5 out-of-scope → SIGNIFICANT_DRIFT |
| 87 | - 6+ out-of-scope → OUT_OF_CONTROL |
| 88 | |
| 89 | ### Step 5: Report |
| 90 | |
| 91 | Output the following structure: |
| 92 | |
| 93 | ``` |
| 94 | ## Scope Report |
| 95 | |
| 96 | - **Planned files**: [count from plan] |
| 97 | - **Actual files changed**: [count from git diff] |
| 98 | - **Out-of-scope files**: [count] |
| 99 | - **Drift**: [X]% ([level]) |
| 100 | - **Status**: ON_TRACK | MINOR_DRIFT | SIGNIFICANT_DRIFT | OUT_OF_CONTROL |
| 101 | |
| 102 | ### In-Scope Changes |
| 103 | - [file] — [matches planned task] |
| 104 | |
| 105 | ### Out-of-Scope Changes |
| 106 | - [file] — [reason: unplanned feature | unrelated refactor | unplanned dep] |
| 107 | |
| 108 | ### Recommendations |
| 109 | - [ON_TRACK]: No action needed. Proceed. |
| 110 | - [MINOR_DRIFT]: Review [file] — consider reverting or acknowledging as intentional. |
| 111 | - [SIGNIFICANT_DRIFT]: PAUSE. Drift is [X]%. Re-align scope with original plan. Suggested cuts: [files to revert] |
| 112 | - [OUT_OF_CONTROL]: STOP. [X]% of changes are unplanned — more drift than planned work. Present full report to user/orchestrator. Do NOT continue until re-scoped. |
| 113 | ``` |
| 114 | |
| 115 | ## Output Format |
| 116 | |
| 117 | ``` |
| 118 | ## Scope Report |
| 119 | - Planned files: 3 | Actual: 5 | Out-of-scope: 2 |
| 120 | - Drift: 40% (SIGNIFICANT_DRIFT) |
| 121 | |
| 122 | ### Out-of-Scope Changes |
| 123 | - src/components/NewWidget.tsx — unplanned feature |
| 124 | - docs/new-feature.md — documentation for unplanned feature |
| 125 | |
| 126 | ### Recommendations |
| 127 | - PAUSE. Drift is 40%. Re-align scope with original plan. |
| 128 | - Suggested cuts: revert src/components/NewWidget.tsx + docs/new-feature.md (reduces drift to 0%) |
| 129 | ``` |
| 130 | |
| 131 | ## Constraints |
| 132 | |
| 133 | 1. MUST compare actual changes against stated scope — not just file count |