spec-driven-refactoring

Guides large codebase refactors through spec writing and two review gates.

2|Updated Jul 18, 2026
One-click install
npx skills add https://github.com/Arasz/ai-badger --skill spec-driven-refactoring-arasz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spec-driven-refactoring
Source: https://github.com/Arasz/ai-badger/tree/main/features/common/skills/spec-driven-refactoring
Command: npx skills add https://github.com/Arasz/ai-badger --skill spec-driven-refactoring-arasz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Large refactors such as schema migrations, concept renames, and structural reorganizations touch many files and accumulate stale assumptions that compound into costly mistakes. This Skill enforces a disciplined workflow: write a specification first, run two independent review gates (pre-implementation consistency and post-implementation quality), then implement against the verified spec. ## Core Features & Use Cases - Spec-first workflow: Analyze all affected contracts (schemas, scripts, tests, docs), write a markdown spec with design decisions, phased implementation order, and risks, then fix review findings before coding. - Dual review gates: A spec review sub-agent checks logical gaps and naming consistency, while a second consistency check verifies the spec's claims against the actual filesystem using terminal ground truth. - Post-implementation verification: Validate schemas, run the project's scaffold tool end-to-end, sweep for stale file references, and update the issue tracker. - Use Case: When renaming a concept across 20+ files including JSON schemas, build scripts, and tests, use this Skill to produce a spec, catch mismatched enum orderings and orphaned test files, and merge safely via sequential PRs. ## Quick Start Ask the agent to refactor the codebase by renaming a core concept across schemas, scripts, tests, and docs using the spec-driven refactoring workflow.

Frequently Asked Questions about spec-driven-refactoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor a large codebase safely across many files?

Write a markdown specification covering design decisions, file changes, schemas, and phased implementation order, then run two review gates before coding. A spec review catches logical gaps, and a consistency check verifies the spec's claims against the actual filesystem.

How to handle schema renames without breaking validation?

Rename the schema field and update the code that writes it in the same commit or phase. For manifest fields, add the new field alongside the old one, update the writer to emit both, then remove the old field after migration completes.

When should I split a refactor into multiple PRs?

Split into sequential PRs when a spec defines eight or more phases. Group by dependency: schemas and plumbing first, consuming library modules second, documentation last, with each PR independently testable and mergeable.

Why does jsonschema fail to resolve $ref to sibling files?

The Python jsonschema library's Draft202012Validator cannot resolve relative $ref paths like sibling schema files without a custom RefResolver. Either inline the enum in every schema or provide a resolver mapping URIs to local files.

What are the limitations of AI code review on refactoring branches?

Sandboxed execution tools may show pre-seeded mock content rather than the real filesystem, producing fabricated analysis. Always use terminal commands like git status and git diff for ground-truth checks before reviewing a refactoring branch.