pinning-down-behavior
Mandates and assists in writing tests that capture current code behavior before making any modifications to legacy systems.
Install
mkdir -p .claude/skills/pinning-down-behavior && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16852" && unzip -o skill.zip -d .claude/skills/pinning-down-behavior && rm skill.zipInstalls to .claude/skills/pinning-down-behavior
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use when checking-coverage-before-change reports an UNCOVERED symbol you must edit — writes characterization (pin-down) tests at the nearest observable seam and verifies they bite before any production edit.Key capabilities
- →Identify the nearest observable seam for testing
- →Write snapshot or approval tests at the chosen seam
- →Run tests to ensure they pass against current code
- →Perform mutation smoke tests to verify test failure on behavior change
- →Proceed with code changes using pin-down tests as regression oracle
- →Escalate to side-by-side execution for critical-path service refactors
How it works
This skill guides the creation of characterization tests at an observable seam, runs them against current code, and verifies they fail when behavior is deliberately altered, ensuring safe refactoring.
Inputs & outputs
When to use pinning-down-behavior
- →Pinning down legacy code behavior
- →Writing characterization tests before refactoring
- →Safety-checking code edits
- →Testing code at an observable seam
About this skill
Pinning Down Behavior
Characterization tests assert what the code does, not what it should do. Whatever is happening right now is, for the duration of your change, exactly what should be happening. Pin it, then change with the net in place.
The Iron Law
NO CHANGE TO UNCOVERED CODE WITHOUT A PIN-DOWN TEST YOU HAVE WATCHED BITE
Process
- Pick the seam. Use the top candidate from
specs/brownfield/seams-<goal>.md(run/seam-finder "<goal>"if missing). If the best seam'stotal_score < 0.5or the symbol sits in askeletons/-flagged god file with no callable boundary, STOP —REQUIRED SUB-SKILL: sprouting-instead-of-editing. - Write snapshot/approval tests at the seam. Python: syrupy (
assert result == snapshot, mask timestamps/IDs with matchers) or pytest-regressions; many input combos through one function → ApprovalTestsverify_all_combinations. JS/TS: Jest/VitesttoMatchSnapshot(). Seam crosses HTTP → VCR.py / Polly.js cassettes. - Run green against the current code. A failing pin-down means your inputs are wrong, not the code. Normalize genuinely nondeterministic fields (timestamps, random IDs) with matchers/scrubbers when you write the pin. Adding a matcher later for a nondeterministic field is harness repair, allowed; matchers may never mask value-bearing fields (amounts, quantities, orderings) — that is
--snapshot-updatein disguise. - Mutation-smoke checkpoint — watch it bite. Deliberately flip one behavior in the target symbol (invert a condition, off-by-one a boundary). Run the pin-downs: they must fail. Revert the flip. A pin-down you never saw fail proves nothing.
- Proceed with the change. The pin-downs are now the regression oracle: byte-identical green after every edit. If a deadline arrives before the pins are green again, ship or demo the last pinned-green commit — the refactor waits; unverified output does not ship.
- Critical-path service refactor with real traffic? Escalate to side-by-side execution (GitHub Scientist pattern) — otherwise the pin-down suite run old-then-new is the default and sufficient.
Common Rationalizations
| Excuse | Reality |
|---|---|
| "Current behavior looks like a bug — I'll fix it while pinning" | Pin the bug too. Characterization asserts what IS. File the fix as a separate /change. |
"Snapshot failed after my refactor — I'll just --snapshot-update" | That diff IS the regression alarm. Updating a snapshot during a refactor destroys the net. |
| "I'll write proper intent-based tests instead" | You don't know the intent — that's why it's uncovered. Pin first; improve tests later. |
| "The mutation smoke is paranoid" | Generated tests frequently don't bite. One extra test run buys the proof. |
| "Teammate says these snapshots are flaky garbage — everyone regenerates" | A flaky pin means nondeterminism you failed to scrub. Fix the matcher; never bless changed values. Social proof is how regressions get normalized. |
| "The diffs look semantically equivalent to me" | The downstream consumer decides equivalence, not your eye. 12.50 → 12.5 on a money field is a behavior change until proven otherwise. |
Red Flags — STOP
- Editing the target symbol before the pin-down exists
- A pin-down suite you never watched fail
--snapshot-update(or editing a snapshot file) anywhere inside a refactor- Pinning "cleaned-up" behavior instead of actual behavior
Checklist
- Seam chosen from seam-finder output (or routed to sprouting)
- Pin-downs green against unmodified code
- Mutation smoke: watched the suite fail on a deliberate flip, then reverted
- Pin-downs byte-identical green after the change
Pin what is, watch it bite, then change. No exceptions without your human partner's permission.
When not to use it
- →When editing the target symbol before a pin-down test exists
- →When using `--snapshot-update` during a refactor
- →When a pin-down suite has not been watched to fail on a deliberate flip
Limitations
- →Requires an UNCOVERED symbol that must be edited
- →Does not allow editing the target symbol before pin-down tests exist
- →Prohibits `--snapshot-update` or editing snapshot files during a refactor
How it compares
This process mandates watching pin-down tests fail on a deliberate behavior flip before any production edit, providing a higher assurance of regression detection than typical test-driven development.
Compared to similar skills
pinning-down-behavior side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| pinning-down-behavior (this skill) | 0 | 2mo | No flags | Advanced |
| qlty-check | 5 | 7mo | Review | Beginner |
| solid | 5 | 6mo | No flags | Advanced |
| code-refactor | 3 | 7mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by cwijayasundara
View all by cwijayasundara →You might also like
qlty-check
parcadei
Code quality checks, formatting, and metrics via qlty CLI
solid
ramziddin
Use this skill when writing code, implementing features, refactoring, planning architecture, designing systems, reviewing code, or debugging. This skill transforms junior-level code into senior-engineer quality software through SOLID principles, TDD, clean code practices, and professional software design.
code-refactor
luongnv89
Systematic code refactoring based on Martin Fowler's methodology. Use when users ask to refactor code, improve code structure, reduce technical debt, clean up legacy code, eliminate code smells, or improve code maintainability. This skill guides through a phased approach with research, planning, and safe incremental implementation.
improvement
tddworks
Guide for making improvements to existing ClaudeBar functionality using TDD. Use this skill when: (1) Enhancing existing features (not adding new ones) (2) Improving UX, performance, or code quality (3) User asks "improve X", "make Y better", or "enhance Z" (4) Small enhancements that don't require full architecture design For NEW features, use implement-feature skill instead.
tdd-workflows-tdd-refactor
sickn33
Use when working with tdd workflows tdd refactor
moai-workflow-ddd
modu-ai
Domain-Driven Development workflow specialist using ANALYZE-PRESERVE-IMPROVE cycle for behavior-preserving code transformation