skill-forge

$npx mdskill add techygarg/lattice/skill-forge

Create new Lattice skills following framework conventions.

  • Guides users through creating atoms, molecules, or refiners without convention violations.
  • Generates SKILL.md and defaults.md or template.md files for the correct tier.
  • Determines tier from user intent and ensures required sections in correct order.
  • Writes files to the correct path with real, specific content.

SKILL.md

.github/skills/skill-forgeView on GitHub ↗
---
name: skill-forge
description: "Create a new Lattice skill — atom, molecule, or refiner — following all framework conventions. Writing skill files manually almost always produces convention violations: wrong section order, missing confirmation gates, defaults.md without the right structure. This skill knows all of that and guides you through it. Use whenever adding any new atom, molecule, or refiner to Lattice, or when the user says 'create a new skill', 'add an atom', 'add a molecule', 'add a refiner', 'build X for Lattice', 'new lattice skill', or 'skill forge'. Does not validate, align docs, or deploy — those are separate skills you run after."
---

# Lattice Skill Forge

**Core responsibility:** Create the right files with the right structure for a new Lattice skill.

**Input:** A description of what the skill should do and when it should trigger.

**Output:** One or more skill files written to the correct path:
- Atom → `skills/atoms/{name}/SKILL.md` + `skills/atoms/{name}/references/defaults.md`
- Molecule → `skills/molecules/{name}/SKILL.md`
- Refiner → `skills/refiners/{name}/SKILL.md` + `skills/refiners/{name}/assets/template.md`

**How to verify this skill did its job:**
- All required files exist at the correct paths
- Folder name matches `name:` frontmatter exactly
- All tier-required sections are present in correct order
- No placeholder content — all sections contain real, specific content

---

## Step 1: Understand intent and select tier

Ask the user: *"What should this skill do, and when should it trigger? Describe it briefly."*

From the description, determine the tier:

| The skill... | Tier |
|---|---|
| Enforces ONE principle with a checklist and anti-pattern scan | **Atom** |
| Orchestrates multiple atoms into a multi-step workflow | **Molecule** |
| Runs a guided interview to produce a `.lattice/standards/*.md` file | **Refiner** |

State your read and confirm with the user. Get explicit tier agreement before proceeding.

---

## Step 2: Requirements alignment (molecules and refiners only)

Before writing a single line of SKILL.md, agree on the design.

Check `knowledge-base/` for an existing requirements doc:
```bash
ls knowledge-base/ | grep -i {name}
```

**If found** → read it, summarise key design decisions, confirm they still reflect intent.

**If not found** → resolve these questions through conversation before writing:

For a **molecule:**
- Which atoms does it compose? (Read `skills/atoms/` to see what exists.)
- Is it **generative** (produces code/artifacts, linear flow) or **planning/interactive** (produces living documents, confirmation gates at each phase)?
- What does it write to `.lattice/`? Which subfolder? (Must be a named subfolder, never the root.)
- What is the session resume behavior — how does it handle an interrupted session?

For a **refiner:**
- Which atom does it configure? (A refiner must have an atom that reads its output.)
- What `paths.{snake_case_key}` config key does it add to `.lattice/config.yaml`?
- What sections does the interview template cover?
- Overlay/override — which is the default mode?

Write a one-paragraph design summary and confirm with the user.

**Do NOT write SKILL.md until design is confirmed.**

---

## Step 3: Read current conventions

Read `PROJECT.md` — the Skill Conventions section. Always read it fresh; never rely on memory.

Note the current skill counts (atoms/molecules/refiners) — they will need updating in PROJECT.md after creation, but that is `skill-align`'s job.

---

## Step 4: Write the skill files

### Writing an Atom

**`skills/atoms/{name}/SKILL.md`** — sections in this exact order:

1. **YAML frontmatter** — `name` (lowercase-hyphenated), `description` (include trigger phrases)
2. **Config Resolution** — always this pattern:
   - Check `.lattice/config.yaml` for `paths.{config_key}`
   - If found: read doc, check `mode: overlay` (merge with defaults) or `mode: override` (replace)
   - If not found: read `./references/defaults.md`
3. **Self-Validation Checklist** — numbered items, bold label, imperative STOP language, clear pass/fail condition and fix per item
4. **Active Anti-Pattern Scan** — checkbox format (`- [ ] **Name**: what it looks like → fix`), minimum 5 items
5. **Ambiguity Signals** — genuine gray areas where two valid approaches exist; resolution guidance for each
6. **Core Principle** — what the atom governs, what it does NOT govern (boundary with other atoms)

**`skills/atoms/{name}/references/defaults.md`** — the embedded defaults:
- Numbered sections (§1, §2...) matching what a future refiner would produce
- Opinionated, specific content — not placeholders
- End with an attribution line

### Writing a Molecule

**`skills/molecules/{name}/SKILL.md`**:

1. **YAML frontmatter** — name, description with trigger phrases
2. **Required Skills** — list every atom as `framework:{name}` with always/conditional qualifier
3. **Mode Detection** (if the molecule has modes) — how modes are invoked, what each changes
4. **Workflow** — numbered steps with clear inputs and outputs per step

**Generative molecule conventions** (`code-forge`, `bug-fix`, `refactor-safely` pattern):
- Linear numbered steps, no confirmation gates
- Pause only on genuine judgment calls via `framework:collaborative-judgment`
- No session resume check needed

**Planning/interactive molecule conventions** (`design-blueprint`, `requirement-forge` pattern):
- Step 1 MUST check for an existing output document. If found: read it, determine earliest incomplete step, resume from there
- Every phase MUST have three things: (1) present the output, (2) ask a specific targeted question, (3) hard gate: *"Do NOT advance to Step N until the user explicitly confirms."*
- Can exit early — partial output is a valid outcome
- Always writes to a named `.lattice/{subfolder}/` — never to `.lattice/` root

### Writing a Refiner

**`skills/refiners/{name}/SKILL.md`** — cover all of these:
- What it produces (output path, two modes, config key, which atom reads it)
- Scope clarification (what this refiner does NOT configure)
- Check for existing doc before starting interview
- Mode selection conversation (overlay vs override, when to use each)
- Facilitation approach (one section at a time, defaults-first, record decisions not discussion)
- Section-by-section guide (reference `./assets/template.md` and its Interview Guidance comments)
- Output assembly rules (overlay: only changed sections; override: all sections)
- Config update instructions (write `paths.{key}` to `.lattice/config.yaml`)
- Document quality checks (one checklist per mode)

**`skills/refiners/{name}/assets/template.md`**:
- Full document structure with `<!-- INTERVIEW GUIDANCE: -->` comments per section
- Each guidance block contains: default content, what to ask, probing questions, what is customisable vs. fixed
- Overlay preamble and override preamble (separate blocks, clearly labeled)
- Footer with project/date/mode placeholders
- INTERVIEW GUIDANCE comments are stripped from the final produced document

---

## Step 5: Confirm files are complete

Before finishing, verify:
- [ ] All required files exist at the correct paths
- [ ] Folder name = `name:` frontmatter field (exactly, character by character)
- [ ] `description:` contains trigger phrases — what a user would actually type to invoke this
- [ ] All tier-specific sections are present in the correct order
- [ ] For atoms: `defaults.md` exists and has §-numbered sections with real content
- [ ] For refiners: `template.md` exists with Interview Guidance comments in every section
- [ ] For planning molecules: every phase has the three-part confirmation gate pattern
- [ ] No section contains placeholder text ("TBD", "TODO", "add content here")

Report what was created and where. Do not run validation, sync, or deploy — those are separate steps.

More from techygarg/lattice

SkillDescription
architecture-compassArchitectural thinking partner for an existing repository — scans the codebase, conducts a structured interview, agrees on current architectural state and recommended direction, and produces a shareable insights document. Scoped to one repository, module, or folder. Does not execute transformation — it orients. Use when the user says 'assess my codebase architecture', 'what direction should my codebase go', 'architecture compass', 'understand my architecture', 'audit architecture drift', 'architectural assessment', or 'help me understand what is wrong with my codebase'.
architecture-refinerFacilitate a structured conversation to define architecture principles for a repository. Supports multiple architecture styles: clean architecture (default), hexagonal / ports & adapters, modular monolith, or custom. Produces a formal architecture document that the corresponding atom will use. Use when setting up a new project, defining architecture standards, or when the user says 'setup architecture', 'define layers', 'architecture principles', 'help me define my architecture', 'hexagonal architecture', 'modular monolith', 'ports and adapters', or 'define my architecture style'.
bug-fixInvestigate, reproduce, and safely fix a bug with regression protection. Composes context, diagnosis, architecture, code quality, and testing guardrails into a reproduce-first repair workflow. Use when the user says 'fix this bug', 'debug this', 'investigate this failure', 'patch this regression', 'repair this issue', or 'why is this broken'.
clean-code-refinerFacilitate 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'.
code-forgeGenerate implementation code from an approved design blueprint or verbal requirements. Composes context anchoring, architecture, clean code, DDD, security, and test quality into an inside-out implementation workflow. Use when moving from design to code, implementing approved contracts, or when the user says 'implement', 'code this', 'build it', 'forge the code', or 'generate the code'.
collaborative-judgmentProtocol for handling ambiguous decisions and missing/conflicting knowledge during code generation, design, and review. Ensures AI surfaces genuine judgment calls with structured options and stops on hallucination risk instead of silently assuming. Use when a decision has multiple valid approaches, when facts are missing or contradictory, when the user asks 'what should we do here?', 'is this a judgment call?', 'should I ask about this?', 'am I guessing here?', 'what are the tradeoffs?', or when deciding between two reasonable architectural or design options. Also composed by molecules to define how judgment calls and clarification requests are surfaced and resolved.
context-anchoringManage per-feature living documents that capture decisions, constraints, and reasoning across AI sessions during active development. Scoped to feature-level work — design, implementation, bugfix, refactor — not for codebase-wide assessments or product-wide specifications (those define their own document lifecycles). Handles creating new context documents, loading existing ones, and enriching them with new decisions. Use when starting a new feature, resuming work, making technical decisions, resolving questions, or when context needs to persist across sessions. Use this skill whenever the user mentions 'load context', 'update context', 'context doc', 'decisions', 'continue where we left off', 'what did we decide', or 'capture this decision'.
ddd-refinerFacilitate a structured conversation to define DDD guardrails for domain design within a repository. Produces a formal ddd-principles.md document that the domain-driven-design atom will use as its override. Use when setting up domain design principles, defining aggregate rules, or when the user says 'setup DDD', 'define domain rules', 'DDD principles', or 'help me define my domain patterns'.
design-blueprintRun a complete design workflow -- from establishing context through 5 progressive design levels to an approved blueprint. Composes context anchoring, design-first methodology, architecture, and DDD into a unified process. Handles both new features (create context doc) and resuming existing work (load context doc). Use when starting a design, planning architecture, or when the user says 'design a feature', 'blueprint', 'start designing', 'plan the architecture', or 'let's design before coding'.
knowledge-primingLoad project-specific context -- tech stack, architecture overview, directory layout, trusted sources, and conventions -- so that all skills operate with awareness of what this project actually is. Use when a knowledge base document exists, or when the user asks about the project's tech stack, architecture, conventions, framework, directory layout, or says 'tell me about this project', 'what are we using?', 'what's our stack?', or 'what framework is this?'. Use the knowledge-priming-refiner to create a knowledge base document.