Files
android/.claude/commands/refactor.md
Patrick Honkonen b811ff1c7f feat(claude): Add Claude command templates
This commit introduces a set of standardized templates for common software engineering tasks to be used with Claude. These templates aim to streamline workflows and ensure consistent, high-quality outputs for tasks like code explanation, code review, refactoring, and implementation planning.

The new command templates are:
- `code-explainer.md`: To explain code at a high level, detailing its function, data flow, dependencies, and potential risks.
- `code-review.md`: To provide structured, actionable feedback on a pull request, covering correctness, style, security, and performance.
- `file-cleaner.md`: To improve the readability of a source file without altering its behavior, focusing on naming, comments, and formatting.
- `implement-it.md`: To translate a user story or ticket into a detailed implementation plan, including architecture, code skeletons, and tests.
- `refactor.md`: To guide the refactoring of legacy code towards a specific goal, emphasizing safety through tests and incremental changes.
- `task-creator.md`: To break down a feature specification into smaller, sprint-ready engineering tasks.
- `test-writer.md`: To generate thorough tests for a function or module, covering unit, integration, and property-based testing.
2026-01-15 10:05:57 -05:00

1.2 KiB

Use this template to refactor legacy code toward a stated goal, with safety.

INPUTS

  • Code - the code to refactor
  • Refactor goal - e.g., improve readability, adopt a pattern, reduce coupling
  • (optional) Constraints

INSTRUCTIONS

  1. Restate the refactor goal and constraints. Preserve behavior.
  2. Propose a target design (patterns, boundaries, contracts).
  3. Provide a refactored version or representative slices.
  4. Explain rationale trade-offs (perf, readability, testability).
  5. Add safety checks: tests, metrics, and rollout steps.
  6. Show an incremental plan of small commits.
  7. Keep lines ≤80 chars.

OUTPUT FORMAT

Goal & constraints

  • Goal:
  • Constraints:

Diagnosis

  • Smells:
  • Risks:

Target design

  • Patterns:
  • Module boundaries:
  • Public interfaces:

Refactored code (slice)

- old
+ new

Rationale

  • Why this is better:
  • Alternatives considered:

Safety & verification

  • Regression tests:
  • Contracts/property checks:
  • Perf baselines:
  • Observability:

Incremental plan

  1. ...
  2. ...

Backout plan

  • How to revert safely:

Follow-ups

  • ...