openlore-analyze-codeb…
Run a full static OpenLore analysis and summarize architecture, call graph, refactoring issues, and duplicate code. Use when…
Identify a high-priority refactoring target, assess its blast radius, and write .openlore/refactor-plan.md without changing code. Use when asked to plan or prioritize a refactor.
$ npx -y skills add clay-good/OpenLore --skill openlore-plan-refactor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/openlore-plan-refactorContext preview
The summary Claude sees to decide when to auto-load this skill.
Identify a high-priority refactoring target, assess its blast radius, and write .openlore/refactor-plan.md without changing code. Use when asked to plan or prioritize a refactor.
name: openlore-plan-refactor description: Identify a high-priority refactoring target, assess its blast radius, and write .openlore/refactor-plan.md without changing code. Use when asked to plan or prioritize a refactor.
Trigger this skill whenever the user asks to **plan a refactoring** on a codebase, with phrasings like:
**This skill modifies no code files.** It only produces `.openlore/refactor-plan.md`. To apply the plan, use the `openlore-execute-refactor` skill.
---
**The plan must be written so that every entry in the change sequence is independently executable and testable.**
Each change = one atomic edit → one diff verification → one full test run → ✅ or rollback.
This is not a final gate at the end. Testing is a mandatory sub-step after **every single change**. The plan must make this cycle explicit and impossible to skip.
**For small models (< 13B parameters)**: each change must touch at most **50 contiguous lines** in the source file. If a logical extraction exceeds this limit, split it into smaller sub-changes, each with its own test gate.
---
If the user has already named a specific file or function to refactor:
---
Ask the user which project to analyze, or confirm the current workspace root.
---
Call the openlore MCP tool `analyze_codebase` with `{"directory": "$DIRECTORY"}`.
If a recent analysis already exists, skip unless the user explicitly requests a fresh run.
---
Call the openlore MCP tool `get_refactor_report` with `{"directory": "$DIRECTORY"}`.
Present the top 5 candidates:
| Function | File | Issues | Priority score | |---|---|---|---|
---
Call the openlore MCP tool `get_duplicate_report` with `{"directory": "$DIRECTORY"}`.
If a top candidate appears in a clone group, prepend a **deduplication note** to the plan: > "⚠️ `<function>` has N near-clones. Consolidate them first to reduce the blast radius of this refactor."
---
Before presenting a choice to the user, check test coverage for the files containing the candidates. Detect the coverage tool from the project:
| Ecosystem | Command | |---|---| | Node.js | `npm test -- --coverage --collectCoverageFrom="<files>"` | | Python | `pytest --cov=<module> --cov-report=term-missing` | | Rust | `cargo tarpaulin --include-files <files>` | | Go | `go test -cover ./...` |
Enrich the candidate table:
| Function | File | Priority | Coverage | |---|---|---|---| | ... | ... | ... | 72% ✅ / 35% ⚠️ / 0% 🚫 |
**Thresholds:**
| Coverage | Badge | Meaning | |---|---|---| | ≥ 70% lines | ✅ | Safe to refactor | | 40–69% lines | ⚠️ | Write characterisation tests first | | < 40% lines | 🛑 | Strongly discouraged | | 0% (no tests) | 🚫 | Blocked — propose a test harness first |
If **all candidates are below 40%**: > "Every high-priority target has insufficient test coverage (< 40%). I recommend writing a minimal test harness for at least one target before proceeding. Would you like me to suggest test cases based on the function signatures?"
---
Get the condensed view of the target function (callers, callees, body, test coverage in one call):
Call the openlore MCP tool `get_minimal_context` with `{"directory": "$DIRECTORY", "functionName": "$FUNCTION_NAME"}`.
**What to read before deciding whether to proceed:**
Then get the full impact analysis:
Call the openlore MCP tool `analyze_impact` with `{"directory": "$DIRECTORY", "symbol": "$FUNCTION_NAME"}`.
Note: risk score (0–100), recommended strategy (`extract` / `split` / `facade` / `delegate`), top 5 upstream callers and downstream callees.
**If `riskLevel` is `"high"` or impact risk score ≥ 60**, check the cluster to set refactor scope:
Call the openlore MCP tool `get_cluster` with `{"directory": "$DIRECTORY", "functionName": "$FUNCTION_NAME"}`.
Read `stats.clusterDensity`:
---
Call the openlore MCP tool `get_subgraph` with:
{"directory": "$DIRECTORY", "functionName": "$FUNCTION_NAME", "direction": "both", "format": "mermaid"}Show the Mermaid diagram to the user.
---
Call the openlore MCP tool `get_low_risk_refactor_candidates` with:
{"directory": "$DIRECTORY", "filePattern": "$TARGET_FILE", "limit": 5}Cross-reference with the subgraph from Step 5: a good first extraction candidate alr
Deterministic, local-first memory and guardrails for AI coding agents with no LLM in the hot path.
Run a full static OpenLore analysis and summarize architecture, call graph, refactoring issues, and duplicate code. Use when…
Transform a feature idea into an annotated story using a Domain Sketch or Constrained Option Tree. Use when asked to brainstorm,…
Debug with OpenLore structural context, an explicit root-cause hypothesis, and RED/GREEN verification. Use when a bug, failure,…
Apply a confirmed .openlore/refactor-plan.md with a test gate after each change. Use when asked to execute or continue an…
Author a new OpenSpec domain specification from deterministic OpenLore MCP evidence. Use when asked to reverse-engineer,…
Implement a brownfield story with OpenLore orientation, risk checks, spec validation, tests, and drift detection. Use when asked…