clean-code-refiner

A guided discussion for defining a repository's rules for writing readable, maintainable code, producing a clean-code document for future work.

In plain words
What is it for?
Use it when setting up coding standards or refining how individual functions, classes, and modules should be written.
Why use it?
It turns team preferences about functions, naming, complexity, and error handling into explicit rules that can be applied consistently.

Skill for Claude CodeCodex

Part of the lattice plugin — 33 skills, 2 agents shipped together

Install

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.

agentmods
npx agentmods add skills/techygarg/lattice/clean-code-refiner
Any agent
npx skills add techygarg/lattice --skill clean-code-refiner
Clone the repo
git clone --depth 1 https://github.com/techygarg/lattice

Made for: Claude Code, Codex.

Or install lattice, the plugin that ships this one along with the rest of its 33 skills, 2 agents.

Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,734 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00084 $0.02734
Opus 5 $0.00042 $0.01367
Sonnet 5 $0.00017 $0.00547
Haiku 4.5 $0.00008 $0.00273

Measured 3d ago against content hash e8eb5ef4d438, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

clean-code-refiner 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 3d 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.

plugins/lattice/skills/clean-code-refiner/SKILL.md · 221 lines

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.

Clean Code Refiner

What This Produces

  • Output: .lattice/standards/clean-code.md (or custom path from .lattice/config.yaml -> paths.clean_code)
  • Two modes:
    • Overlay (mode: overlay): A slim document containing only sections that differ from the defaults. The clean-code atom reads its embedded defaults first, then applies this document's sections on top. This is the expected common case.
    • Override (mode: override): A comprehensive standalone document that fully replaces the atom's embedded defaults. For teams with fundamentally different coding standards.
  • Default mode: Overlay -- produces only what the user wants to change
  • Config key: paths.clean_code in .lattice/config.yaml
  • Template: Read ./assets/template.md for the full document structure, default content, and interview guidance comments

Scope Clarification

This skill defines the rules of code craftsmanship -- how individual functions, classes, and modules should be written. It does not define architecture (that is the architecture-refiner) or domain modeling (that is the ddd-refiner). The boundaries:

  • Clean code -- function size, naming, complexity, error handling, testability, abstraction discipline
  • Clean architecture -- layers, dependency direction, command/query flows, structural placement
  • DDD -- aggregates, entities, value objects, domain events, repository patterns

Before You Begin

Check for existing documents

Before starting the interview, check whether a custom document already exists:

  1. Read .lattice/config.yaml -- does paths.clean_code point to a file?
  2. If yes, read that file. Ask the user:
    • "You already have a custom clean code document. Would you like to revise it (update specific sections), start fresh (new interview), or add to it (add new sections)?"
    • Revise: Load the existing document, walk through only the sections the user wants to change, and update in place.
    • Start fresh: Proceed with the full interview flow below.
    • Add to it: Skip to the "New Sections" part of the interview.
  3. If no config or no existing document, proceed with the full interview flow.

Read the full file on GitHub · 221 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

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.

  1. 3d ago First seen · 221 lines · 84 tokens per session scan A e8eb5ef4d438

Subscribe to this mod's changes

clean-code-refiner is a skill published in the GitHub repository techygarg/lattice (183 stars, last pushed 4d ago), licensed MIT. It adds 84 tokens to every session and 2,734 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.

Related

Other skills, from other repositories

xiaoyaoclaw-workspace-initializer

OpenClaw workspace initialization & standardization. Sets up a proper agent home: standard directory structure (projects/tasks/outputs/knowledge/scripts/ memory/tmp) + WORKSPACE.md rules + multi-agent config safety (config.patch, never config.apply) + memory log. Use when an agent enters a new/empty workspace root, or…

dtsola/xiaoyaoclaw-workspace-initializer · 105 tokens

learn

Search, install, update, and rate AI agent skills from agentskill.sh (100,000+ skills). Use when the user asks to find skills, install extensions or plugins, discover new capabilities, check what skills are available, or says "how do I do X" when a skill might help. Also handles listing installed skills, checking for…

agentskill-sh/ags · 115 tokens

review-skill

Review and improve AI agent skills (SKILL.md files) against best practices from the Agent Skills specification and Anthropic's authoring guidelines. Scores skills on 10 quality dimensions, identifies specific issues, and rewrites problem areas. Use when creating, editing, auditing, or improving agent skills. Triggers…

agentskill-sh/ags · 90 tokens

building-chatgpt-apps

Guides creation of ChatGPT Apps with interactive widgets using OpenAI Apps SDK and MCP servers. Use when building ChatGPT custom apps with visual UI components, embedded widgets, or rich interactive experiences. Covers widget architecture, MCP server setup with FastMCP, response metadata, and Developer Mode…

mjunaidca/mjs-agent-skills · 87 tokens

memory-systems

Design and implement memory architectures for agent systems. Use when building agents that need to persist state across sessions, maintain entity consistency, or reason over structured knowledge.

mjunaidca/mjs-agent-skills · 35 tokens

multi-agent-patterns

Design multi-agent architectures for complex tasks. Use when single-agent context limits are exceeded, when tasks decompose naturally into subtasks, or when specializing agents improves quality.

mjunaidca/mjs-agent-skills · 38 tokens