Skip to main content
ClaudeWave
Skill132 repo starsupdated 2d ago

language-idioms-refiner

The language-idioms-refiner skill guides users through a structured interview to document language-specific idioms and patterns for a repository, producing a `.lattice/standards/language-idioms.md` file with six required sections (Error Handling, Type System, Naming Conventions, Testing Patterns, Parameter Design, Dependency Management) that multiple atoms consume to adapt their pseudocode defaults. Use this skill when setting up a new project, switching to a different programming language, or when the user explicitly requests language configuration, idiom definition, or pattern adaptation for a specific language.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/techygarg/lattice /tmp/language-idioms-refiner && cp -r /tmp/language-idioms-refiner/skills/refiners/language-idioms-refiner ~/.claude/skills/language-idioms-refiner
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Language Idioms Refiner

## What This Produces

- **Output**: `.lattice/standards/language-idioms.md` (or custom path from `.lattice/config.yaml` -> `paths.language_idioms`)
- **Mode**: Always standalone -- no embedded language defaults exist in atoms to overlay on. For revisions, load existing document and update sections in place.
- **Config keys**:
  - `language` (top-level) -- language identifier (e.g., `go`, `rust`, `python`, `java`, `typescript`)
  - `paths.language_idioms` -- path to the produced document
- **Template**: Read `./assets/template.md` for the full document structure, pre-populated examples, and interview guidance comments
- **Consumed by**: Multiple atoms reference specific sections by heading name:

| Section | Consumed by |
|---------|------------|
| **Error Handling** | `clean-code` atom (§8), `secure-coding` atom (§1 trust boundary messages) |
| **Type System & Object Model** | `clean-code` atom (§1 SRP/cohesion), `domain-driven-design` atom (entities, VOs, aggregates) |
| **Naming Conventions** | `clean-code` atom (§4) |
| **Testing Patterns** | `test-quality` atom (§5 naming, §4 isolation, §6 builders) |
| **Parameter & Function Design** | `clean-code` atom (§2 function size, §5 parameters) |
| **Dependency Management** | `clean-code` atom (§9 testability/DI), `architecture` atom (dependency direction) |

These six section headings are the **stable contract**. Atoms reference them by name. Additional sections can be added by consumers but these six must be present.

## Scope Clarification

This document captures **how the project's language expresses engineering patterns** -- the language-level idioms that atoms need to adapt their pseudocode defaults. Clear boundaries:

| Concern | Where It Belongs | Not Here |
|---------|-----------------|----------|
| Project identity, tech stack, directory layout | `knowledge-priming` atom | No project structure or framework docs |
| Code craftsmanship rules (thresholds, heuristics) | `clean-code` atom / overlay | No function size limits or DRY rules |
| Architecture layers, dependency direction | `architecture` atom / overlay | No layer definitions |
| Domain modeling guardrails | `domain-driven-design` atom / overlay | No aggregate rules |
| Team-specific preferences within language | Atom-specific overlays | No team decisions (see below) |

**Key distinction from atom overlays**: This document describes *how the language works*. Atom overlays describe *how the team works within the language*.

- **Language idioms doc**: "Go uses explicit error returns (`if err != nil`), not exceptions"
- **Clean-code overlay**: "We use `fmt.Errorf('context: %w', err)` for wrapping, custom error types for domain errors"

Language idioms are facts about the language. Atom overlays are team choices.

## Before You Begin

### Check for existing documents

1. Read `.lattice/config.yaml` -- does `paths.language_idioms` point to a file?
2. If yes, read that file. Ask the user:
   - "You already have a language idioms document for **[language]**. Would you like to **revise** it (update specific sections), **start fresh** (new interview), or **switch language**?"
   - Revise: Load the existing document, walk through only the sections the user wants to change.
   - Start fresh: Proceed with the full interview flow below.
   - Switch language: Proceed with full interview for the new language; existing document will be replaced.
3. If no config or no existing document, proceed with the full interview flow.

### Detect the language

Determine the project language before starting the interview:

1. **From config**: Check `.lattice/config.yaml` for `language` key.
2. **From project files** (if no config key):
   - `package.json` → TypeScript / JavaScript
   - `tsconfig.json` → TypeScript (confirm over JavaScript)
   - `go.mod` → Go
   - `pom.xml` or `build.gradle` or `build.gradle.kts` → Java or Kotlin
   - `Cargo.toml` → Rust
   - `requirements.txt` or `pyproject.toml` or `setup.py` → Python
   - `Gemfile` → Ruby
   - `*.csproj` or `*.sln` → C# / .NET
   - `Package.swift` → Swift
3. **Multiple languages detected**: Ask the user which is the primary language. One language-idioms document per project (covers the primary language).
4. **No detection**: Ask the user directly.

Present the detected language: "I detected this is a **Go** project (found `go.mod`). I'll propose Go-idiomatic patterns for each section. You can confirm or adjust."

## Interview Flow

This refiner works differently from other refiners. Instead of showing defaults and asking "change or keep?", it **proposes language-specific content** and asks "does this match your team's usage?"

### Step 1: Confirm language and version

"I detected **[Language] [version]**. Is this correct?"

Record language and version. These go in the document frontmatter.

### Step 2: Walk through sections with proposals

For each of the 6 sections:

1. **Propose** pre-populated content based on the detected language (see Language-Specific Proposals below).
2. **Present** the proposal: "Here's what I'd recommend for [Language]. Does this match how your team uses [Language]?"
3. **User confirms** → record as-is.
4. **User adjusts** → discuss specifics, record their version.

### Step 3: Additional sections

After the 6 core sections, ask: "Any language-specific patterns I should add? For example: concurrency patterns, memory management, async/await idioms, or framework-specific conventions."

Record any additional sections the user wants.

### Step 4: Produce document

Assemble and write the document.

## Section-by-Section Interview Guide

Read `./assets/template.md` and follow the `<!-- INTERVIEW GUIDANCE: -->` comments for each section.

### The 6 core sections

| # | Section | What It Captures |
|---|---------|-----------------|
| 1 | **Error Handling** | Language error philosophy (exceptions, error returns, Result types), error propagation patterns, error creation idioms |
| 2 | **Type System & Object
skill-alignSkill

Audit and fix all Lattice documentation, README, docs/, GitHub issue templates, and CLAUDE.md to ensure they are fully aligned with the current skill inventory. Documentation drift is the most common source of user confusion in Lattice — a skill exists in the codebase but not in the docs, or a renamed skill leaves a stale reference in the bug report template. If you've made any change to skills/ and haven't run this, run it now. Use when the user says 'align docs', 'audit docs', 'update documentation', 'skill align', 'check docs are in sync', 'audit skill inventory', 'ensure docs are aligned', 'are the docs up to date', or 'what needs updating'. Standalone — does not call other skills.

skill-forgeSkill

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.

skill-reviewSkill

Deep behavioral audit of a Lattice skill — proposes 3 review personas relevant to the skill, runs independent scenario analysis from each persona's perspective, then merges only the high-confidence, practical findings into a severity-ordered gap report with proposed fixes. Structural validation (conventions, cross-references) is skill-validate's job — this skill finds gaps that would realistically surface when someone actually uses the skill: missing scenario handling, ambiguous instructions, silent failure cases, and behavioral inconsistencies. Filters out theoretical edge cases, low-likelihood speculation, and findings owned by other skills. Use after writing or significantly changing any skill, or when the user says 'review this skill', 'deep review', 'does this skill work', 'find gaps in this skill', 'stress test this skill', 'review from different angles', or 'skill review'. Standalone — does not call other skills.

skill-validateSkill

Validate any Lattice SKILL.md against all tier conventions — atoms, molecules, and refiners. Catches structural errors, broken cross-references, and convention violations before they reach the repo. If you just wrote or modified a Lattice skill file and haven't run this yet, run it now — manual review consistently misses the same categories of errors this skill is specifically designed to catch. Use when the user says 'validate this skill', 'check this skill', 'does this follow conventions', 'review this skill file', 'check my SKILL.md', or 'skill validate'. Reports PASS/FAIL with specific file-and-section findings and actionable fixes. Standalone — does not call other skills.

architecture-compassSkill

Architectural 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-refinerSkill

Facilitate 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'.

architectureSkill

Enforce architectural rules when generating or modifying code. Defaults to clean architecture; supports any architecture style via the architecture-refiner. Validates layer responsibilities, dependency direction, and structural constraints using the loaded architecture rules. Use when generating code, reviewing architecture, creating new files, or when the user mentions 'architecture', 'layers', 'structure', 'dependency rules', 'hexagonal architecture', 'ports and adapters', 'modular monolith', or 'onion architecture'. Also use when reviewing generated code for structural compliance.

bug-fixSkill

Investigate, 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'.