$npx -y skills add techygarg/lattice --skill language-idioms-refinerFacilitate a structured conversation to define language-specific idioms and patterns for a repository. Produces a language-idioms.md document consumed by multiple atoms to adapt pseudocode defaults to the project's language. Use when setting up a new project, switching languages,
| 1 | # Language Idioms Refiner |
| 2 | |
| 3 | ## What This Produces |
| 4 | |
| 5 | - **Output**: `.lattice/standards/language-idioms.md` (or custom path from `.lattice/config.yaml` -> `paths.language_idioms`) |
| 6 | - **Mode**: Always standalone -- no embedded language defaults exist in atoms to overlay on. For revisions, load existing document and update sections in place. |
| 7 | - **Config keys**: |
| 8 | - `language` (top-level) -- language identifier (e.g., `go`, `rust`, `python`, `java`, `typescript`) |
| 9 | - `paths.language_idioms` -- path to the produced document |
| 10 | - **Template**: Read `./assets/template.md` for the full document structure, pre-populated examples, and interview guidance comments |
| 11 | - **Consumed by**: Multiple atoms reference specific sections by heading name: |
| 12 | |
| 13 | | Section | Consumed by | |
| 14 | |---------|------------| |
| 15 | | **Error Handling** | `clean-code` atom (§8), `secure-coding` atom (§1 trust boundary messages) | |
| 16 | | **Type System & Object Model** | `clean-code` atom (§1 SRP/cohesion), `domain-driven-design` atom (entities, VOs, aggregates) | |
| 17 | | **Naming Conventions** | `clean-code` atom (§4) | |
| 18 | | **Testing Patterns** | `test-quality` atom (§5 naming, §4 isolation, §6 builders) | |
| 19 | | **Parameter & Function Design** | `clean-code` atom (§2 function size, §5 parameters) | |
| 20 | | **Dependency Management** | `clean-code` atom (§9 testability/DI), `architecture` atom (dependency direction) | |
| 21 | |
| 22 | 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. |
| 23 | |
| 24 | ## Scope Clarification |
| 25 | |
| 26 | 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: |
| 27 | |
| 28 | | Concern | Where It Belongs | Not Here | |
| 29 | |---------|-----------------|----------| |
| 30 | | Project identity, tech stack, directory layout | `knowledge-priming` atom | No project structure or framework docs | |
| 31 | | Code craftsmanship rules (thresholds, heuristics) | `clean-code` atom / overlay | No function size limits or DRY rules | |
| 32 | | Architecture layers, dependency direction | `architecture` atom / overlay | No layer definitions | |
| 33 | | Domain modeling guardrails | `domain-driven-design` atom / overlay | No aggregate rules | |
| 34 | | Team-specific preferences within language | Atom-specific overlays | No team decisions (see below) | |
| 35 | |
| 36 | **Key distinction from atom overlays**: This document describes *how the language works*. Atom overlays describe *how the team works within the language*. |
| 37 | |
| 38 | - **Language idioms doc**: "Go uses explicit error returns (`if err != nil`), not exceptions" |
| 39 | - **Clean-code overlay**: "We use `fmt.Errorf('context: %w', err)` for wrapping, custom error types for domain errors" |
| 40 | |
| 41 | Language idioms are facts about the language. Atom overlays are team choices. |
| 42 | |
| 43 | ## Before You Begin |
| 44 | |
| 45 | ### Check for existing documents |
| 46 | |
| 47 | 1. Read `.lattice/config.yaml` -- does `paths.language_idioms` point to a file? |
| 48 | 2. If yes, read that file. Ask the user: |
| 49 | - "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**?" |
| 50 | - Revise: Load the existing document, walk through only the sections the user wants to change. |
| 51 | - Start fresh: Proceed with the full interview flow below. |
| 52 | - Switch language: Proceed with full interview for the new language; existing document will be replaced. |
| 53 | 3. If no config or no existing document, proceed with the full interview flow. |
| 54 | |
| 55 | ### Detect the language |
| 56 | |
| 57 | Determine the project language before starting the interview: |
| 58 | |
| 59 | 1. **From config**: Check `.lattice/config.yaml` for `language` key. |
| 60 | 2. **From project files** (if no config key): |
| 61 | - `package.json` → TypeScript / JavaScript |
| 62 | - `tsconfig.json` → TypeScript (confirm over JavaScript) |
| 63 | - `go.mod` → Go |
| 64 | - `pom.xml` or `build.gradle` or `build.gradle.kts` → Java or Kotlin |
| 65 | - `Cargo.toml` → Rust |
| 66 | - `requirements.txt` or `pyproject.toml` or `setup.py` → Python |
| 67 | - `Gemfile` → Ruby |
| 68 | - `*.csproj` or `*.sln` → C# / .NET |
| 69 | - `Package.swift` → Swift |
| 70 | 3. **Multiple languages detected**: Ask the user which is the primary language. One language-idioms document per project (covers the primary language). |
| 71 | 4. **No detection**: Ask the user directly. |
| 72 | |
| 73 | 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." |
| 74 | |
| 75 | ## Interview Flow |
| 76 | |
| 77 | This refiner works differently from other refin |