---
name: scope-prune
description: "Prune a completed implementation or PR back to the minimum durable change for its agreed problem. Use when asked what went beyond scope, whether the diff is too large, or to cut speculative behavior and tests after implementation."
title: scope-prune
canonical_url: https://skilld.dev/gh/khoahyh/skills/scope-prune
last_updated: 2026-10-08T03:00:39.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install khoahyh/skills/scope-prune`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/scope-prune`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/khoahyh/skills/scope-prune) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/scope-prune`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/scope-prune --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/scope-prune --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Scope Prune

Start with the problem, not the patch. The target is the smallest durable implementation of the **agreed outcome**, not the fewest lines and not a general cleanup of nearby code.

## 1. Recover the boundary

Recover the accepted user outcome and later explicit decisions from the conversation and linked context. Use a Feature Contract, plan, or PR as evidence, not as independent authority to enlarge that outcome. Separate agreed behavior from suggested mechanisms, and record the in-scope failure path, non-goals, real compatibility obligations, and proof needed to know the problem stays solved. If the boundary is missing or contradictory, ask for the decision that would change what can be removed; do not infer product intent from the implementation or its tests.

Establish the requested diff baseline before judging size. For a PR or branch, include commits since the intended base plus staged, unstaged, and relevant untracked work; distinguish inherited and unrelated changes. For a narrower target, follow the user's range. Use [`subtract`'s Change Scopes](../subtract/references/change-scopes.md) to protect the index and history when editing staged or committed work.

## 2. Challenge the entire diff

Inspect every changed surface, including production code, tests, fixtures, docs, configuration, and generated output. Trace additions through their callers and the accepted failure path. For each coherent change, classify it as:

- **Essential:** directly delivers the agreed result.
- **Necessary support:** required for that result to work safely in a realistic supported path, including a named compatibility, security, or data-integrity obligation.
- **Extra:** adjacent feature, speculative guard or fallback, generalized abstraction, redundant representation, broad refactor, or test that proves only an extra behavior or mirrors code without closing a risk.
- **Uncertain:** removal depends on missing contract or consumer evidence.

Put the burden on additions: what concrete failure of the agreed outcome would removing this introduce? A passing test, an imaginable edge case, or “while we're here” is not an answer. Trace coupled extras as a group: deleting an unneeded behavior may also delete its validator, branch, fixture, test, and documentation. Conversely, preserve the smallest mechanism that satisfies a real obligation; do not turn scope control into a brittle fix.

## 3. Cut and prove

An explicit request to scope the implementation down authorizes the supported edits. Otherwise return the ranked cuts and their evidence before changing code. Delete extra behavior and its dependent artifacts first, then collapse or narrow remaining machinery. Keep unrelated work intact; make follow-up suggestions instead of implementing them. If an uncertain item changes the product contract or risk posture, leave it intact and ask the smallest necessary question.

Treat every added test as part of the diff to justify. Keep it when it detects a meaningful regression in the agreed outcome or a distinct, realistic failure that existing tests would miss. Remove tests for behavior being cut, duplicated coverage, speculative permutations, and reversible, low-impact edits where the test merely mirrors the implementation. A passing test does not justify keeping either the test or the behavior it asserts. Run focused tests appropriate to the surviving change and complete required checks. Broaden or repeat testing only when a new edit, failure, or unresolved risk invalidates that evidence. Inspect the complete final diff and status; passing checks cannot substitute for the scope judgment.

Finish with a concise accounting: agreed outcome, baseline, cuts made or proposed, why each retained non-obvious addition is necessary, before/after footprint by meaningful surfaces, verification, and unresolved boundary decisions. Stop when every changed surface has a disposition, the agreed behavior has evidence, and unrelated work is untouched. If no cut is justified, say why the size is necessary.
