Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add techygarg/lattice --skill refactor-safelygit clone --depth 1 https://github.com/techygarg/latticeWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/techygarg/lattice/refactor-safely)<a href="https://agentmods.dev/skills/techygarg/lattice/refactor-safely"><img src="https://agentmods.dev/badge/skills/techygarg/lattice/refactor-safely/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/techygarg/lattice/refactor-safely"><img src="https://agentmods.dev/badge/skills/techygarg/lattice/refactor-safely.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00082 | $0.02755 |
| Opus 5.5 | $0.00033 | $0.01102 |
| Sonnet 5.5 | $0.00016 | $0.00551 |
| Haiku 4.5 | $0.00008 | $0.00276 |
Grade A, and why
refactor-safely scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 230 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Refactor Safely
Required Skills
Load these skills based on refactor scope (see Steps 3, 5, 6 for conditional use):
framework:knowledge-priming-- Load project context so the refactor grounds in the real codebase. (always)framework:context-anchoring-- Find and load the feature's context doc; capture approved plans and decisions in it. (always)framework:learning-harvest-- Load prior operational learnings at session start; harvest new ones at session end. (always)framework:collaborative-judgment-- Surface trade-offs in structure, seams, and migration sequence instead of silently assuming. (always)framework:clean-code-- Readability, responsibility boundaries, local craft. (always)framework:test-quality-- Characterization tests and the safety net. (always)framework:design-first-- Target-structure planning for significant structural changes. (conditional: Step 3)framework:architecture-- Layer placement and dependency direction. (conditional: responsibilities move across layers in Steps 5/6)framework:domain-driven-design-- Aggregate boundaries and domain behavior. (conditional: domain rules move or sharpen in Step 6)framework:secure-coding-- Trust bounds, authorization, sensitive data handling. (conditional: security-sensitive code touched in Step 6)
Additional Instructions
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:
- Show them verbatim under "Additional instructions (from config):".
- 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.
Workflow
Step 1: Establish Refactor Context
Start from the current pain, not from a preferred abstraction.
- Identify the target area: a module, service, aggregate, endpoint path, or subsystem.
- Clarify why the refactor is needed: mixed responsibilities, duplication, wrong-layer logic, coupling, poor testability, or unreadable control flow.
- Clarify what the user expects to improve: simpler structure, correct layer placement, smaller units, clearer domain behavior, easier testing, or safer extension points.
- Run
framework:learning-harvestLoad behavior. Focus hint: "refactoring session — focus: structural health, quality signals". - Run
framework:context-anchoringDocument Discovery to check for an existing context doc covering the affected feature/module:- Found → Load behavior. Honor every logged decision and constraint as an active commitment while planning the refactor. The doc already contains an approved refactor plan (preservation boundaries + target structure) → confirm it still matches the user's intent, then resume at Step 4 unless the user wants to revisit the plan first.
- Not found → Proceed from the conversation and the current code. Do not block planning on a missing context doc.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 12d ago Changed · +9 lines 2c15e97df45b
- 1mo ago First seen · 221 lines · 82 tokens per session scan A 6206df716793
refactor-safely is a skill published in the GitHub repository techygarg/lattice (207 stars, last pushed 13d ago), licensed MIT. It adds 82 tokens to every session and 2,755 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
verify
Verify Elixir/Phoenix changes — compile, format, and test in one loop. Use after implementation, before PRs, or after fixing bugs.
build-scenario-tests
Inspect an unfamiliar repository, turn a focused Markdown behavior scenario into a deterministic test in the repository's native test stack, run it, and preserve traceability between intent and code. Use when asked to add scenario tests, compile acceptance criteria or Given/When/Then Markdown into executable tests…
run-smoke-tests
Inspect an unfamiliar repository, interpret a broad Markdown user journey at runtime, operate the real product through its supported web, API, CLI, desktop, or mobile surface, and produce an auditable pass, fail, or blocked judgment with screenshots, logs, recordings, and a step timeline when available. Use when asked…
session-profiler
Profile and debug Hermes sessions from their JSONL transcripts. Find a session and its subagents, build a queryable event table, summarize the work as a hierarchical table of contents, break down wall time, inference, tools, tokens, and estimated cost per agent, identify errors and improvement opportunities, and…
code-standards
Apply a disciplined engineering workflow to any code change. Use whenever implementing a feature, fixing a bug, or refactoring — before writing code, not after. Walks orient → baseline → smallest change → test → verify → self-review, and enforces language-agnostic hard gates (don't mass-reformat, keep the linter and…
debug
Investigate a bug to its root cause systematically — reproduce, trace the data flow, test one hypothesis at a time — then fix it with a regression test. Use when something is broken and the user has a symptom or error message to chase down.