architecture-compass
Architectural thinking partner for an existing repository — scans the codebase, conducts a structured interview, agrees on current architectural state and…
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
$ npx -y skills add techygarg/lattice --skill refactor-safely --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/refactor-safelyContext preview
The summary Claude sees to decide when to auto-load this skill.
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
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)
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:
Present:
End the step with an explicit gate:
> "Does this refactor plan look correct? Should I proceed to Step 4: characterization test
Composable AI skills that teach assistants structured thinking — design-first, context-aware, and architecture-guided.
Repo: techygarg/lattice
Architectural thinking partner for an existing repository — scans the codebase, conducts a structured interview, agrees on current architectural state and…
Facilitate a structured conversation to define architecture principles for a repository. Supports multiple architecture styles: clean architecture (default),…
Enforce architectural rules when generating or modifying code, and validate proposed designs before approval (design mode). Defaults to clean architecture;…
Investigate, reproduce, and safely fix a bug with regression protection. Composes context, diagnosis, architecture, code quality, and testing guardrails into a…
Facilitate a structured conversation to define clean code principles for a repository. Produces a formal clean-code.md document that the clean-code atom will…
Apply clean code principles when generating or modifying implementation code. Enforces function focus, naming clarity, complexity management, error handling,…