---
name: docxology/template-refactoring
source: https://app.decimal.ai/s/docxology-template-refactoring@1/SKILL.md
source_sha256: 4197d1e1234f
---

# Refactoring

## Natural invoke

- "Extract analysis logic from scripts/ into src/"
- "Split infrastructure/validation monolith into smaller modules"
- "Rename public API with all call sites updated"

## Inputs to confirm

- **Scope** — paths/modules affected.
- **Behavior** — preserve externally observable behavior unless user requests breaking change.

## Workflow

1. **Baseline** — run tests on scope; record coverage.

2. **Move logic** — from scripts to `src/` or `infrastructure/`; keep orchestrators thin.

3. **Update imports** — repo-wide grep; fix tests and docs.

4. **Migration** — if breaking, document in project/infrastructure AGENTS.md; no silent API removal.

5. **Verify** — pytest + ruff/mypy on public scope paths; pipeline smoke if project scripts moved.

## Deliverables

- Before/after structure summary
- Test command output showing pass + coverage maintained

## Verification commands

```bash
uv run pytest <affected-test-path> -v
uv run python -m infrastructure.project.public_scope lint-paths | xargs uv run ruff check
uv run python scripts/pipeline/stage_01_test.py --project <project>  # when project scope
```

## When NOT to use

- **New capability** → [feature-addition](../feature-addition/SKILL.md)
- **Docs-only restructure** → [documentation-creation](../documentation-creation/SKILL.md)

## References

- [`docs/core/architecture.md`](../../core/architecture.md)
- Module line-count gate: `uv run python scripts/gates/module_line_count_check.py`