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 agentmods add skills/techygarg/lattice/refactor-safelynpx 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.svg" alt="Measured on agentmods" height="20"></a>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 | $0.00082 | $0.02634 |
| Opus 5 | $0.00041 | $0.01317 |
| Sonnet 5 | $0.00016 | $0.00527 |
| Haiku 4.5 | $0.00008 | $0.00263 |
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 5d 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 — 221 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)
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.
- 5d ago First seen · 221 lines · 82 tokens per session scan A 6206df716793
refactor-safely is a skill published in the GitHub repository techygarg/lattice (183 stars, last pushed 6d ago), licensed MIT. It adds 82 tokens to every session and 2,634 once invoked, about $0.0004 per session on Opus 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
name-your-business
Generate, refine, compare, and when needed validate distinctive names for startups, AI products, developer tools, protocols, open-source projects, apps, product families, local businesses, services, companies, nonprofits, and other organizations. Use when asked to name or rename a business, brand, product, venture…
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…
async-learning-teacher
Transform saved links, papers, articles, posts, videos, and reference collections into approachable AI teaching artifacts for later study. Use when a user wants to queue learning material, create a readable explanation from a source, teach a paper or post step by step, or run an interactive tutor that validates…
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…
plan-create
Create structured implementation plans for autonomous TDD development. Use for new features, multi-file changes, or anything requiring multiple steps or tests. Triggers on aspirational openers ("let's build", "let's start building", "I want to make", "I want an app that", "help me build"), capability lists ("users…
forge
Plan, execute, and validate complex multi-step tasks with automatic retry and memory.