home / skills / oimiragieo / agent-studio / minimal-code-changes-rule

minimal-code-changes-rule skill

/.claude/skills/_archive/dead/minimal-code-changes-rule

This skill helps enforce minimal code changes to reduce bugs and technical debt by guiding targeted refactors and scoped updates.

npx playbooks add skill oimiragieo/agent-studio --skill minimal-code-changes-rule

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
1.5 KB
---
name: minimal-code-changes-rule
description: Enforces the principle of making minimal code changes to avoid introducing bugs or technical debt in any file.
version: 1.0.0
model: sonnet
invoked_by: both
user_invocable: true
tools: [Read, Write, Edit]
globs: '**/*.*'
best_practices:
  - Follow the guidelines consistently
  - Apply rules during code review
  - Use as reference when writing new code
error_handling: graceful
streaming: supported
---

# Minimal Code Changes Rule Skill

<identity>
You are a coding standards expert specializing in minimal code changes rule.
You help developers write better code by applying established guidelines and best practices.
</identity>

<capabilities>
- Review code for guideline compliance
- Suggest improvements based on best practices
- Explain why certain patterns are preferred
- Help refactor code to meet standards
</capabilities>

<instructions>
When reviewing or writing code, apply these guidelines:

- Only modify sections of the code related to the task at hand.
- Avoid modifying unrelated pieces of code.
- Accomplish goals with minimal code changes.
  </instructions>

<examples>
Example usage:
```
User: "Review this code for minimal code changes rule compliance"
Agent: [Analyzes code against guidelines and provides specific feedback]
```
</examples>

## Memory Protocol (MANDATORY)

**Before starting:**

```bash
cat .claude/context/memory/learnings.md
```

**After completing:** Record any new patterns or exceptions discovered.

> ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.

Overview

This skill enforces the principle of making minimal code changes to avoid introducing bugs or technical debt. It guides reviews and edits so changes are limited to the scope of the task, preserving existing behavior and reducing risk. The skill is language-agnostic but tuned for JavaScript projects and common development workflows.

How this skill works

The skill inspects code diffs, PR descriptions, and the target files to identify unnecessary edits, broad refactors, or unrelated formatting changes. It reports specific lines or hunks that can be reverted or reduced, suggests focused alternatives, and gives step-by-step edits that accomplish the goal with minimal disruption. It also flags risky changes and recommends tests to validate the narrow change set.

When to use it

  • When reviewing pull requests to keep changes scoped and safe
  • When implementing a small bugfix and avoiding accidental regressions
  • When updating logic in legacy code where broad refactors increase risk
  • When enforcing code review rules in CI or team workflows
  • Before merging to main branches to reduce technical debt accumulation

Best practices

  • Change only the functions, modules, or lines required for the task
  • Avoid reformatting or renaming unrelated code in the same commit
  • Write focused commits with clear messages describing scope
  • Add or update tests that verify only the intended behavior
  • Document any deviation from minimal changes and why it’s necessary

Example use cases

  • Review a PR that fixes a calculation bug but also contains unrelated whitespace and refactors; produce a reduced patch suggestion
  • Suggest alternate edits that achieve a feature change without touching unrelated modules
  • Audit a set of commits to identify churn and recommend squashing or splitting to isolate the minimal change
  • Provide a checklist for developers to follow when making small fixes in legacy code
  • Generate targeted unit tests that validate only the modified behavior

FAQ

What counts as a minimal change?

A minimal change modifies only the code necessary to achieve the intended fix or feature while preserving existing behavior elsewhere.

When is a larger refactor acceptable?

Larger refactors are acceptable when backed by tests, a clear rollout plan, and when the benefits outweigh the increased short-term risk.