SkillAtlasSkill 详情

clean-code-refiner

Composable AI skills that teach assistants structured thinking — design-first, context-aware, an...

审核状态:已审核Quality 80Security 62

复制安装命令

用 Codex 或 Claude 安装复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它先审查 Skill 页面再帮你安装。

复制前请先查看来源、License 和安全提示。

项目 README

来源文件:README.md

抓取于 2026年9月11日

Lattice

lattice

Composable AI skills that teach assistants structured thinking — design-first, context-aware, and architecture-guided.

License: MIT Claude Code Cursor PRs Welcome martinfowler.com StarMapper

What is Lattice?

AI coding assistants jump straight to code, silently make design decisions, forget constraints mid-conversation, and produce output nobody reviewed against real standards. Lattice fixes this with composable skills in three tiers — atoms, molecules, refiners — that embed battle-tested engineering disciplines plus a living context layer that accumulates your project's standards, decisions, and review insights across every feature cycle.

Three principles guided Lattice's design:

  • Skills over prompts — versioned, team-owned skill files in the repository beat personal prompts on one developer's machine
  • Composability over monoliths — small single-purpose skills that combine into workflows beat one instruction document that tries to cover everything
  • Living context over static config — the .lattice/ folder grows smarter with every feature cycle rather than being configured once and forgotten

The Three Tiers

TierPurpose
AtomsSingle-principle guardrails — clean code, architecture, DDD, secure coding, test quality, design-first, and more
MoleculesMulti-step workflows that compose atoms — design, implement, refactor, fix, review
RefinersGuided interviews that produce project-specific standards, customizing how atoms behave for your team

The Composability Model

See How It Works for the full skill inventory and mechanics.

The Pipeline

Skills form a delivery lifecycle: requirement-forge → design-blueprint → code-forge → review, with refactor-safely and bug-fix covering structural and defect-driven work. requirement-forge starts the pipeline — it acts as a senior PM + BA pair to produce structured feature specs in .lattice/requirements/ that feed directly into design-blueprint. For teams with existing codebases, architecture-compass sits before the pipeline — it scans the repository, runs a structured interview, and produces an agreed architectural direction that orients the team before any code changes begin. Each stage consumes and produces artifacts in .lattice/, growing the living context layer.

Feature Lifecycle Pipeline

Getting Started

  1. Install Lattice — choose the path that fits your setup:

    Option A — Claude Code plugin (also works in Cursor — reads Claude Code skills automatically)

    /plugins marketplace add techygarg/lattice
    /plugins install lattice
    /reload-plugins
    

    Option B — Codex-compatible plugin package

    codex plugin marketplace add techygarg/lattice
    codex plugin add lattice@lattice
    codex plugin list | rg -i lattice
    

    The Codex plugin manifest lives in .codex-plugin/ and is registered by .agents/plugins/marketplace.json. Like every host plugin here, it's a thin manifest only — it points at the same shared, flat skills/ folder every other host uses, plus the verification runner script (scripts/run-verification.sh) — Codex has no subagent concept, so verification always runs the script directly rather than via a subagent. Grok (.grok-plugin/) and Kimi (.kimi-plugin/) follow the same pattern.

    Option C — Clone and install locally (any AI tool)

    git clone https://github.com/techygarg/lattice.git
    cd lattice
    ./tools/install.sh /absolute/path/to/your/skills/folder
    

    Pass the skills directory for your tool: ~/.claude/skills/ for Claude Code, .cursor/skills/ for Cursor, or any tool's skills folder.

    Option D — Agent Plugins 1.0-conformant clients A root plugin.json conforming to the open, vendor-neutral Agent Plugins standard ships alongside the host-specific manifests above — any conformant client auto-discovers skills straight from the skills/ folder with zero extra install steps. Shipped in Codex CLI, Cursor, VS Code / GitHub Copilot, and Kiro as of this writing.

    See docs/plugins.md for the full per-host status table and how to add a new host.

    Try it immediately. The repo includes sample/ — a realistic .NET 8 User Service spec with requirements, domain concepts, and constraints already written. Copy the sample/ folder contents into any empty directory and follow the steps below.

  2. Run /lattice-init in your AI tool's chat — scans the project, suggests refiners in priority order, creates .lattice/config.yaml. All skill commands (/lattice-init,/requirement-forge, /design-blueprint, /code-forge, etc.) are typed in the AI chat, not the terminal.

  3. Spec (optional but recommended) — /requirement-forge acts as a senior PM + BA pair to define epics and feature specs before any design begins. Accepts existing PRDs, feature lists, or a verbal description. Produces .lattice/requirements/ as direct input to design-blueprint.

  4. Design — /design-blueprint walks through five progressive design levels before any code is written.

  5. Implement — /code-forge generates implementation from the approved blueprint, applying all quality atoms.

  6. Review — /review audits the change and persists insights into .lattice/ for the next cycle.

Learn More

  • Origin Story — why Lattice exists, how five collaboration patterns became an installable framework, and the design philosophy behind it
  • How It Works — full skill inventory, composability mechanics, atoms/molecules/refiners in depth, the pipeline
  • Practical Guide — scenario-driven Q&A: getting started, customization, workflow, transformation, team usage, troubleshooting
  • Architecture Compass — the architectural thinking partner: why it exists, what to expect, and how a session works
  • Configuration Reference — every .lattice/config.yaml key documented
  • Framework Intelligence — verification passes, feedback loops, AI compliance techniques
  • Collaborative Judgment — why AI should ask on genuine judgment calls or missing/conflicting facts and how it works at runtime
  • Verification Agent — why the verifier subagent exists, the cost model behind it, and how to enable the done-gate manually or automatically per project
  • The Article Series — the five collaboration patterns Lattice operationalizes (martinfowler.com)

Dev Skills

Helper skills for creating and maintaining Lattice itself — see dev-skills/.

StarMapper

StarMapper

License

MIT

开发与工程文档与办公

高风险

  • 来源需自行核对维护者身份。
  • 包含脚本或命令调用,安装前请复核。
  • 未检测到明显外部权限要求。
  • 存在潜在风险命令,请谨慎安装。
  • 扫描发现:1 条。

Codex — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/techygarg/lattice.git
  3. 将 "skills/clean-code-refiner" 文件夹复制到 Codex 的 skills 目录中。
  4. 重启 Codex 让新的 skill 生效。

Codex — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Codex 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Codex 让新的 skill 生效。

Claude Code — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/techygarg/lattice.git
  3. 将 "skills/clean-code-refiner" 文件夹复制到 Claude Code 的 skills 目录中。
  4. 重启 Claude Code 让新的 skill 生效。

Claude Code — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Claude Code 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Claude Code 让新的 skill 生效。

Cursor — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/techygarg/lattice.git
  3. 将 "skills/clean-code-refiner" 文件夹复制到 Cursor 的 skills 目录中。
  4. 重启 Cursor 让新的 skill 生效。

Cursor — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Cursor 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Cursor 让新的 skill 生效。

GitHub Copilot — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/techygarg/lattice.git
  3. 将 "skills/clean-code-refiner" 文件夹复制到 GitHub Copilot 的 skills 目录中。
  4. 重启 GitHub Copilot 让新的 skill 生效。

GitHub Copilot — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 GitHub Copilot 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 GitHub Copilot 让新的 skill 生效。

Windsurf — Git Clone 安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 克隆仓库:git clone https://github.com/techygarg/lattice.git
  3. 将 "skills/clean-code-refiner" 文件夹复制到 Windsurf 的 skills 目录中。
  4. 重启 Windsurf 让新的 skill 生效。

Windsurf — 手动复制安装

  1. 安装前请先查看来源仓库和风险报告。
  2. 从源仓库下载 SKILL.md 及相关文件。
  3. 在 Windsurf 的 skills 目录中创建新文件夹。
  4. 将所有 skill 文件复制到新文件夹中。
  5. 重启 Windsurf 让新的 skill 生效。
查看 SKILL.md 原文
name: clean-code-refiner
description: "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 use as its override. Use when setting up coding standards, defining code quality rules, or when the user says 'setup clean code', 'define coding standards', 'code quality principles', 'coding guidelines', or 'help me define my code standards'."

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.

Scan the repository

Look for signals that inform the conversation:

  • Linter configs: ESLint, Pylint, Rubocop, etc. -- what rules are already enforced? What complexity thresholds are configured?
  • Formatter configs: Prettier, Black, gofmt -- what formatting decisions are already automated?
  • Existing code style: Are functions generally short or long? Imperative or functional? Heavy on comments or sparse?
  • Test patterns: What testing framework? Co-located or separate? Mocking patterns?
  • Language: TypeScript, Python, Go, Java, etc. -- language idioms affect naming conventions and error handling patterns.

Share relevant findings with the user at the start: "I noticed your project has ESLint configured with max-complexity: 15 and uses Prettier for formatting. I'll use that as context."

If the project is new with no code, proceed with pure defaults as the starting point.

Choosing the Mode

The first decision in the conversation. Present the three options:

"How would you like to define your clean code principles?

  1. Customize specific sections (overlay) -- Keep the defaults and change only what differs for your project. This produces a slim document. Most teams choose this.
  2. Define everything from scratch (override) -- Walk through all sections and produce a comprehensive standalone document.
  3. Add project-specific sections only (overlay with additions) -- Keep all defaults as-is and add new sections for your team's specific rules.

The defaults cover standard clean code practices well. Option 1 is recommended unless your coding standards are fundamentally different."

Map the choice:

  • Options 1 and 3 -> mode: overlay
  • Option 2 -> mode: override

Facilitation Approach

Conversation style

  • One section at a time. Do not dump all questions at once. Walk through the template sequentially.
  • Defaults-first. For each section, briefly summarize the default, then ask if it matches. Do not read the entire default verbatim -- summarize the key points and ask.
  • Record decisions, not discussion. The output document reads as a specification, not meeting notes. "We discussed X and decided Y" is wrong. "Y" is right.
  • Probe, don't interrogate. Use the probing questions in the template guidance comments as follow-ups when the user's answer is ambiguous, not as a checklist.

For overlay mode

This should be fast. Many sections will be "keep as-is."

  1. Present each section's default briefly (a 2-3 sentence summary, not full content).
  2. Ask: "Does this match your project, or would you like to change it?"
  3. If the user says it matches -> skip it (section will NOT appear in the output).
  4. If the user wants changes -> dive into that section, discuss the specifics, record the changes.
  5. At the end, ask: "Any sections you'd like to add that aren't in the defaults?" (e.g., language-specific idioms, framework patterns).
  6. Only sections the user changed or added appear in the output document.

For override mode

This is thorough. Every section gets attention and appears in the output.

  1. Walk through every section in full detail.
  2. User confirms, modifies, or replaces each section.
  3. All sections appear in the output -- defaults for unchanged ones, user's version for changed ones.

Common scenarios

  • "I agree with everything" -> No custom document needed. Tell the user: "The embedded defaults are already active and match your preferences. No custom document is needed -- the clean-code atom will use the defaults automatically."
  • "I agree except one section" -> Overlay mode, interview that one section only.
  • "We use shorter functions" -> Overlay §2 (thresholds change from ~20 to whatever the team prefers).
  • "We use Result types instead of exceptions" -> Overlay §8 (error handling patterns change fundamentally).
  • "We're a functional team -- no classes" -> Overlay §1 (remove class cohesion guidance), §5 (parameter patterns for functional style), §9 (functional patterns emphasis).
  • "We want stricter complexity limits" -> Overlay §3 (adjust thresholds, e.g., max complexity 5 instead of 10).
  • "We have language-specific idioms" -> Overlay with additions, e.g., §11 Go-specific patterns, §12 Python-specific patterns.

Section-by-Section Interview Guide

Read ./assets/template.md and follow the <!-- INTERVIEW GUIDANCE: --> comments for each section. Those comments contain the specific questions to ask, probing questions, and what is customizable vs fixed.

Cross-section dependency table

Decisions in early sections affect later sections. When a user changes an early section, flag the dependent sections:

Decision inAffectsHow
§1 -- SRP scope (classes vs functions-only)§2 (extraction targets), §10 (checklist)Functional codebases extract to functions only; class-based codebases also extract to classes
§2 -- Function size thresholds§3 (complexity thresholds), §10 (checklist)Shorter functions imply lower complexity budgets
§3 -- Complexity thresholds§2 (function size)Lower complexity limits may require stricter function size
§4 -- Naming conventions§7 (comment necessity)Better naming reduces the need for "what" comments
§5 -- Parameter design§1 (SRP signals)Long parameter lists often signal SRP violations
§8 -- Error handling strategy§9 (testability patterns)Result types vs exceptions change how error paths are tested

When a dependency is triggered, inform the user: "Since you changed [X], we should also review [Y] -- it's affected by that decision."

Overlay-specific section flow

For each of the 10 default sections:

  1. Summarize the section's key points in 2-3 sentences.
  2. Ask: "Does this match your project?"
  3. Yes -> Move to the next section. This section will not appear in the output.
  4. No -> Dive into the section details using the template guidance. Produce the user's version.
  5. After all 10 sections, ask about new sections.

Override-specific section flow

For each of the 10 default sections:

  1. Present the section's full content.
  2. Ask: "Does this work as-is, or would you like to modify it?"
  3. As-is -> Include the default content in the output unchanged.
  4. Modify -> Discuss changes, produce the modified version.
  5. After all 10 sections, ask about new sections.
  6. All sections go in the output.

Output Assembly

For overlay mode

  1. YAML frontmatter: mode: overlay
  2. Overlay preamble text (from template)
  3. Table of contents listing only the included sections
  4. Only the sections the user changed or added
  5. Each section must be self-contained -- it is a complete replacement of that section in defaults. Do not write diffs or partial sections.
  6. Section headings must match defaults.md exactly (the atom matches sections by heading)
  7. New sections (§11+) are included after the default sections
  8. Footer with project name, date, mode

For override mode

  1. YAML frontmatter: mode: override
  2. Override preamble text (from template)
  3. Full table of contents (all 10+ sections)
  4. All sections: defaults for unchanged, user's version for changed, new sections at the end
  5. Footer with project name, date, mode

For both modes

Strip all <!-- INTERVIEW GUIDANCE: --> comments from the output. The final document is a clean specification.

Determine output path:

  1. If .lattice/config.yaml exists and has paths.clean_code, use that path.
  2. Otherwise, default to .lattice/standards/clean-code.md.

Write the document:

  1. Create .lattice/standards/ directory (and .lattice/ parent) if it does not exist.
  2. Write the document to the determined path.

Update config:

  1. If .lattice/config.yaml does not exist, create it with:
    paths:
      clean_code: .lattice/standards/clean-code.md
    
  2. If .lattice/config.yaml exists but has no paths.clean_code, add the key. Preserve all existing content.
  3. If .lattice/config.yaml exists and already has the key, no config change needed.

Confirm to user: "Your clean code document has been written to [PATH] in [overlay|override] mode. The clean-code atom will now use it [on top of the defaults | instead of the defaults]."

Document Quality Checks

Before writing the final document, verify:

Overlay mode checks

  • Each included section is self-contained and complete (not a diff or partial section)
  • Section headings match defaults.md exactly (for section matching by the atom)
  • No <!-- INTERVIEW GUIDANCE: --> comments remain
  • Frontmatter has mode: overlay
  • Only changed/added sections are included -- unchanged sections are omitted

Override mode checks

  • Every section from the template is present (§1 through §10, plus any new sections)
  • Thresholds are consistent across sections (function size aligns with complexity limits)
  • Code examples use pseudocode (language-agnostic, same style as defaults.md)
  • Validation checklist (§10) is consistent with the principles defined in §1 through §9
  • No <!-- INTERVIEW GUIDANCE: --> comments remain
  • Frontmatter has mode: override
  • Document is readable as a standalone specification

Both modes

  • Frontmatter is valid YAML with correct mode value
  • Document is well-formatted markdown
  • Config file (.lattice/config.yaml) is correctly updated
  • Output path exists and is writable

发现问题?提交给管理员复核

评分:

评论 (0)

暂无评论,成为第一个评论者吧!