architecture-compass
Architectural thinking partner for an existing repository — scans the codebase, conducts a structured interview, agrees on…
Restructure existing code safely without changing externally observable behavior. Composes context, design, architecture, code quality, and testing guardrails into a characterization-first refactoring workflow. Use when the user says 'refactor this', 'clean this up', 'untangle
Claude Code
$ npx -y skills add techygarg/lattice --skill refactor-safely --agent claude-code
Codex
$ npx skills add techygarg/lattice --skill refactor-safely -a codex -y
Cursor
$ npx skills add techygarg/lattice --skill refactor-safely -a cursor -y
Gemini CLI
$ npx skills add techygarg/lattice --skill refactor-safely -a gemini-cli -y
GitHub Copilot
$ npx skills add techygarg/lattice --skill refactor-safely -a github-copilot -y
OpenCode
$ npx skills add techygarg/lattice --skill refactor-safely -a opencode -y
Windsurf
$ npx skills add techygarg/lattice --skill refactor-safely -a windsurf -y
name: refactor-safely description: "Restructure existing code safely without changing externally observable behavior. Composes context, design, architecture, code quality, and testing guardrails into a characterization-first refactoring workflow. Use when the user says 'refactor this', 'clean this up', 'untangle this module', 'move this to the right layer', 'simplify this code', or 'improve this structure'."
Load these skills based on refactor scope (see Steps 3, 5, 6 for conditional use):
1. `framework:knowledge-priming` -- Load project context so the refactor grounds in the real codebase. (always) 2. `framework:context-anchoring` -- Find and load the feature's context doc; capture approved plans and decisions in it. (always) 3. `framework:learning-harvest` -- Load prior operational learnings at session start; harvest new ones at session end. (always) 4. `framework:collaborative-judgment` -- Surface trade-offs in structure, seams, and migration sequence instead of silently assuming. (always) 5. `framework:clean-code` -- Readability, responsibility boundaries, local craft. (always) 6. `framework:test-quality` -- Characterization tests and the safety net. (always) 7. `framework:design-first` -- Target-structure planning for significant structural changes. (conditional: Step 3) 8. `framework:architecture` -- Layer placement and dependency direction. (conditional: responsibilities move across layers in Steps 5/6) 9. `framework:domain-driven-design` -- Aggregate boundaries and domain behavior. (conditional: domain rules move or sharpen in Step 6) 10. `framework:secure-coding` -- Trust bounds, authorization, sensitive data handling. (conditional: security-sensitive code touched in Step 6)
**STOP: Before Step 1, read `additional_instructions.refactor_safely` (one line or a list) from `.lattice/config.yaml`.** No file or no key → skip silently.
When lines are found:
1. Show them verbatim under "Additional instructions (from config):". 2. **Highest priority — apply them for the whole session, including on resume.** On any conflict with anything else in this skill — steps, gates, STOP rules — or with its Required Skills, standards documents, or operational learnings, the config line wins.
Start from the current pain, not from a preferred abstraction.
End the step by summarizing the intent in one sentence:
> "Refactor X to improve Y while preserving Z."
**STOP:** If you cannot state both the improvement target and the preservation target that clearly, continue clarifying with the user before planning any changes.
**Persistence check**:
Refactoring changes structure, **not behavior**. Make the preservation contract explicit before proposing any structural edits.
List the behaviors that must remain unchanged:
Also list explicit **out-of-scope changes**:
If the desired outcome requires changing preserved behavior, stop and discuss what the task actually is — a bug fix (`/bug-fix`), a feature change (`/design-blueprint`), or a broader redesign. **STOP:** Never proceed as a refactor after making one of those determinations.
**Zero Refactor Rule**: make no structural code changes until the user approves both the target structure and the transition plan.
For small refactors the plan may be brief. For larger ones, use `framework:design-first` selectively:
Composable AI skills that teach assistants structured thinking — design-first, context-aware, and architecture-guided.
Architectural thinking partner for an existing repository — scans the codebase, conducts a structured interview, agrees on…
Facilitate a structured conversation to define architecture principles for a repository. Supports multiple architecture styles:…
Enforce architectural rules when generating or modifying code, and validate proposed designs before approval (design mode).…
Investigate, reproduce, and safely fix a bug with regression protection. Composes context, diagnosis, architecture, code quality,…
Facilitate a structured conversation to define clean code principles for a repository. Produces a formal clean-code.md document…
Apply clean code principles when generating or modifying implementation code. Enforces function focus, naming clarity, complexity…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.