agentleFS
glrodaszglrodasz/dotfiles/skills/minimal-code-changes/SKILL.md

minimal-code-changes

Skill20 starsChanged 14 days agoMITView on GitHub

Enforce minimal, narrowly scoped modifications when implementing features, fixing bugs, changing tests, updating configuration, or otherwise editing an existing codebase — no opportunistic renaming, reformatting, abstraction, dependency upgrades, architecture changes, or unrelated fixes; an explicitly requested refactor is allowed but kept strictly within the named scope. Use when the user explicitly asks for a minimal change — "minimal diff", "minimal code changes", "smallest possible change", "surgical change", "only change what's needed", "don't touch anything else", "don't touch unrelated code", "keep the existing structure", "no refactors", or "cambios mínimos". Not for ordinary edits that don't ask for a minimal scope.

The file

Show its rules and text

We split this skill into the rules it gives an agent

24 rules. About 0 are common, 24 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈24

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat code outside the necessary change boundary as read-only.

    line 19
  2. Distinctive:

    Follow the codebase's existing local conventions.

    line 33
  3. Distinctive:

    No narrower implementation is reasonably available.

    line 42
  4. Distinctive:

    When a broader refactor is truly unavoidable, keep it as small as possible and explicitly explain why it was required.

    line 51
  5. Distinctive:

    Do not perform any of the following unless explicitly requested or required by the refactor gate:

    line 56
  6. Distinctive:

    Add, remove, or upgrade dependencies.

    line 63
  7. Distinctive:

    Run repository-wide formatters, linters with auto-fix, codemods, or generators that create broad churn.

    line 66
  8. Distinctive:

    When the request is ambiguous, choose the least expansive reasonable interpretation and state the assumption.

    line 87
  9. Distinctive:

    Read enough surrounding code to understand the target and its immediate dependencies.

    line 92
  10. Distinctive:

    Search for existing patterns that the patch should follow.

    line 93
  11. Distinctive:

    Do not turn repository exploration into a cleanup exercise.

    line 95
  12. Distinctive:

    Use this default boundary:

    line 99
  13. Distinctive:

    Outside the boundary: read-only unless the user explicitly expands the scope.

    line 105
  14. Distinctive:

    Prefer changing an existing condition, branch, argument, or local implementation over introducing a new abstraction.

    line 107
  15. Distinctive:

    Add comments or documentation only when required to explain new non-obvious behavior.

    line 117
  16. Distinctive:

    Avoid destructive Git operations and never revert unrelated work.

    line 119
  17. Distinctive:

    Do not alter lockfiles unless dependency resolution actually changed.

    line 120
  18. Distinctive:

    Run the most focused relevant checks available, such as a targeted test, type check, lint command, or build for the affected package.

    line 124
  19. Distinctive:

    Add or modify only tests that directly verify the requested behavior.

    line 127
  20. Distinctive:

    If an unrelated pre-existing issue blocks validation, report it separately.

    line 130
  21. Distinctive:

    If not, revert that line. Remove formatting churn, reordered imports, renamed variables, generated noise, and incidental cleanup, then …

    line 140
  22. Distinctive:

    Do:: Add the narrowest guard at the failing path and add a regression test.

    line 154
  23. Distinctive:

    Do:: Update the responsible mapping, its type only if required, and focused tests.

    line 161
  24. Distinctive:

    Keep the final report focused:

    line 176

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Minimal Code Changes

Implement the requested behavior with the smallest correct semantic diff.

Treat code outside the necessary change boundary as read-only. Set the default refactor budget to zero. Do not improve code merely because an improvement becomes apparent while working nearby.

Minimal does not mean cryptic or fragile. Keep the patch correct, maintainable, and consistent with the existing local style without expanding its scope.

Priorities

Apply these priorities in order:

  1. Satisfy the requested behavior correctly.
  2. Preserve existing behavior outside the request.
  3. Minimize the semantic and textual diff.
  4. Follow the codebase's existing local conventions.
  5. Improve elegance only within the lines that must change.

Refactor gate

Permit a refactor only when every condition below is true:

  1. It is directly necessary to implement the requested behavior correctly or to prevent a regression introduced by the patch.
  2. No narrower implementation is reasonably available.
  3. It remains inside the smallest enclosing function, component, module, or explicitly requested area.
  4. It preserves external behavior except for the requested change.
  5. It can be validated with focused checks.

Code cleanliness, stylistic preference, duplication reduction, modernization, or future flexibility alone are not sufficient reasons.

When a broader refactor is truly unavoidable, keep it as small as possible and explicitly explain why it was required. Do not use it to include adjacent improvements.

Changes forbidden by default

Do not perform any of the following unless explicitly requested or required by the refactor gate:

  • Rename variables, functions, types, files, directories, or public symbols.
  • Move code between files or reorganize modules.
  • Extract helpers, introduce generalized abstractions, or redesign interfaces.
  • Replace design patterns, libraries, frameworks, or APIs.
  • Add, remove, or upgrade dependencies.
  • Change public contracts, schemas, data models, or configuration shapes.
  • Reformat untouched code or reorder imports across unrelated sections.
  • Run repository-wide formatters, linters with auto-fix, codemods, or generators that create broad churn.
  • Fix unrelated bugs, warnings, type errors, security findings, spelling, comments, or dead code.
  • Expand error handling beyond the path affected by the request.
  • Rewrite tests simply to make them cleaner.
  • Modify generated files when changing their source is sufficient.

A serious unrelated issue may be reported as a separate follow-up, but must not be folded into the patch without authorization unless leaving it untouched would make the requested implementation immediately unsafe.

Phase 1 — Define the change contract

Before editing, identify:

  • The exact requested outcome.
  • The narrowest relevant file, symbol, function, component, or configuration entry.
  • The existing behavior that must remain unchanged.
  • The focused validation needed to prove the change.

When the request is ambiguous, choose the least expansive reasonable interpretation and state the assumption. Do not silently broaden the task.

Phase 2 — Inspect narrowly

Read enough surrounding code to understand the target and its immediate dependencies. Search for existing patterns that the patch should follow.

Do not turn repository exploration into a cleanup exercise.

Phase 3 — Establish the change boundary

Use this default boundary:

  • Primary boundary: the exact function, class, component, module, or configuration entry responsible for the requested behavior.
  • Secondary boundary: immediate callers, dependencies, types, or tests only when the primary change cannot work correctly without them.
  • Outside the boundary: read-only unless the user explicitly expands the scope.

Prefer changing an existing condition, branch, argument, or local implementation over introducing a new abstraction.

Phase 4 — Implement surgically

  • Edit the fewest files and lines reasonably possible.
  • Preserve existing control flow, and make none of the changes forbidden by default.
  • Reuse current dependencies and established local patterns.
  • Match nearby formatting.
  • Add comments or documentation only when required to explain new non-obvious behavior.
  • Preserve pre-existing user changes in the working tree.
  • Avoid destructive Git operations and never revert unrelated work.
  • Do not alter lockfiles unless dependency resolution actually changed.

Phase 5 — Validate narrowly

Run the most focused relevant checks available, such as a targeted test, type check, lint command, or build for the affected package.

Add or modify only tests that directly verify the requested behavior. Do not rewrite broad test suites, regenerate unrelated snapshots, or fix unrelated failures.

If an unrelated pre-existing issue blocks validation, report it separately. Do not repair it unless the requested change cannot be delivered safely without doing so.

Phase 6 — Verify the diff

Review the final diff before finishing.

For every changed line, ask: Can this line be justified directly by the requested behavior, its focused validation, or a necessary compatibility constraint?

If not, revert that line. Remove formatting churn, reordered imports, renamed variables, generated noise, and incidental cleanup, then rerun the Phase 5 checks.

Examples

Add a timeout to one request

Do: Pass the timeout through the existing client call and update the focused test.

Do not: Introduce a new HTTP client factory, rename environment variables, centralize all request settings, or upgrade the HTTP library.

Fix a null-value crash in a parser

Do: Add the narrowest guard at the failing path and add a regression test.

Do not: Rewrite the parser, redesign its return type, rename neighboring fields, or clean up unrelated branches.

Add one field to an existing response

Do: Update the responsible mapping, its type only if required, and focused tests.

Do not: Reorganize the response layer, replace the serializer, or normalize every related endpoint.

Explicitly requested refactor

Do: Refactor only the named service, component, or pattern and preserve behavior with focused validation.

Do not: extend the refactor into adjacent modules simply because they use similar code.

Report

Keep the final report focused:

## <requested change> — <file or area>

- Changed: <behavior> in <file>
- Checks: <focused command> → <result>
- Untouched: <adjacent issue left alone — only if important for the user to know>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.