From lattice
Facilitates structured conversation to define language-specific idioms and patterns like error handling and naming, producing language-idioms.md for atoms to adapt pseudocode. Use for new projects, language switches, or 'adapt for Go/Rust/Python'.
npx claudepluginhub techygarg/lattice --plugin latticeThis skill uses the workspace's default tool permissions.
- **Output**: `.lattice/standards/language-idioms.md` (or custom path from `.lattice/config.yaml` -> `paths.language_idioms`)
Facilitates structured conversation to define clean code principles for a repository, producing clean-code.md override for clean-code atom. Use for coding standards or quality rules.
Define and enforce coding standards that reduce cognitive load, prevent bugs, and make code maintainable. Use when establishing style guides or linting rules.
Applies language-specific style guides for TypeScript, Python, Go, JavaScript, and HTML/CSS when writing, reviewing, refactoring, or setting up code files to ensure consistency and best practices.
Share bugs, ideas, or general feedback.
.lattice/standards/language-idioms.md (or custom path from .lattice/config.yaml -> paths.language_idioms)language (top-level) -- language identifier (e.g., go, rust, python, java, typescript)paths.language_idioms -- path to the produced document./assets/template.md for the full document structure, pre-populated examples, and interview guidance comments| 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.
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.
if err != nil), not exceptions"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.
.lattice/config.yaml -- does paths.language_idioms point to a file?Determine the project language before starting the interview:
.lattice/config.yaml for language key.package.json → TypeScript / JavaScripttsconfig.json → TypeScript (confirm over JavaScript)go.mod → Gopom.xml or build.gradle or build.gradle.kts → Java or KotlinCargo.toml → Rustrequirements.txt or pyproject.toml or setup.py → PythonGemfile → Ruby*.csproj or *.sln → C# / .NETPackage.swift → SwiftPresent 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."
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?"
"I detected [Language] [version]. Is this correct?"
Record language and version. These go in the document frontmatter.
For each of the 6 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.
Assemble and write the document.
Read ./assets/template.md and follow the <!-- INTERVIEW GUIDANCE: --> comments for each section.
| # | 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 Model | Classes vs structs, interfaces (nominal vs structural), inheritance vs composition, generics, type safety idioms |
| 3 | Naming Conventions | Case conventions, visibility modifiers, acronym style, package/module naming, idiomatic patterns |
| 4 | Testing Patterns | Test framework idioms, test organization, assertion patterns, mocking approach, test naming style |
| 5 | Parameter & Function Design | Argument passing idioms, options/config patterns, multiple returns, named parameters, function signatures |
| 6 | Dependency Management | DI approach (container vs manual), interface placement, wiring patterns, import/module conventions |
| Decision in | Affects | How |
|---|---|---|
| §1 Error Handling | §4 Testing | Error patterns determine how error paths are tested |
| §2 Type System | §5 Parameters, §6 Dependencies | Object model shapes function signatures and DI approach |
| §3 Naming | §4 Testing | Naming conventions apply to test names too |
For well-known languages, pre-populate each section with idiomatic defaults. The interview confirms or adjusts these. For unrecognized languages, ask open-ended questions.
| Section | Proposal summary |
|---|---|
| Error Handling | Explicit error returns (value, err := ...), if err != nil, error wrapping with fmt.Errorf("context: %w", err), sentinel errors for expected cases, no exceptions |
| Type System | Structs with methods (receiver functions), implicit interfaces (structural typing), composition via embedding, no inheritance, no classes |
| Naming | Exported = capitalized, unexported = lowercase, short names in small scopes, acronyms fully uppercase (HTTP, ID), package name is part of identifier (http.Client not http.HTTPClient) |
| Testing | Table-driven tests, t.Run for subtests, testing.T parameter, test files _test.go co-located, no assertion library required (stdlib comparisons) |
| Parameters | Accept interfaces return structs, functional options pattern for config (WithTimeout(5*time.Second)), multiple return values, no method overloading |
| Dependencies | Pass interface parameters (not constructor DI), define interfaces at consumer not provider, no DI container, explicit wiring in main() or cmd/ |
| Section | Proposal summary |
|---|---|
| Error Handling | Result<T, E> for recoverable, panic! for unrecoverable, ? operator for propagation, thiserror for library errors, anyhow for application errors |
| Type System | Structs + impl blocks, traits (explicit implementation), enums with data (algebraic types), ownership/borrowing, no inheritance, no null (Option<T> instead) |
| Naming | snake_case functions/variables, PascalCase types/traits, SCREAMING_SNAKE constants, lifetime names short ('a, 'b) |
| Testing | #[test] attribute, #[cfg(test)] mod tests in same file, integration tests in tests/ directory, assert_eq!/assert! macros |
| Parameters | Ownership: borrow (&T) vs move, generic bounds (impl Trait), builder pattern for complex config, no default parameters |
| Dependencies | Trait objects (dyn Trait) or generics (impl Trait) for abstraction, no DI container, explicit construction |
| Section | Proposal summary |
|---|---|
| Error Handling | EAFP over LBYL (try/except, not if-checks), context managers (with) for cleanup, custom exceptions inheriting from base classes, raise/except |
| Type System | Classes, dataclasses (@dataclass), protocols for structural typing (PEP 544), duck typing, type hints encouraged but optional at runtime |
| Naming | snake_case functions/variables, PascalCase classes, SCREAMING_SNAKE constants, _private convention (single underscore), __dunder__ for magic methods |
| Testing | pytest preferred, fixtures for setup/teardown, @pytest.mark.parametrize for data-driven tests, plain assert (pytest rewrites), test files test_*.py |
| Parameters | **kwargs for options, named/keyword arguments, default values, dataclass or TypedDict for config objects |
| Dependencies | Constructor injection with protocols/ABCs, or function parameters, no heavyweight DI container (or dependency-injector if needed) |
| Section | Proposal summary |
|---|---|
| Error Handling | Java: unchecked exceptions preferred over checked (modern style), custom exceptions extend RuntimeException. Kotlin: sealed class Result pattern, runCatching, no checked exceptions |
| Type System | Java: classes, interfaces, records (16+), sealed classes (17+). Kotlin: data classes, sealed hierarchies, null safety (?), extension functions |
| Naming | camelCase variables/methods, PascalCase classes/interfaces, SCREAMING_SNAKE constants, packages lowercase.dotted |
| Testing | JUnit 5, @Test, @ParameterizedTest, @Nested for grouping, Mockito (Java) / MockK (Kotlin), AssertJ for fluent assertions |
| Parameters | Java: builder pattern for >3 params, method overloading. Kotlin: named arguments, default values, data class config |
| Dependencies | Constructor injection (Spring, Guice, or manual), DI containers are idiomatic, program to interfaces |
| Section | Proposal summary |
|---|---|
| Error Handling | try/catch with custom Error subclasses, typed error handling optional (Result pattern via libraries), no checked exceptions |
| Type System | Interfaces, type aliases, union/intersection types, generics, unknown over any, discriminated unions for state |
| Naming | camelCase variables/functions, PascalCase types/classes/enums, SCREAMING_SNAKE constants, no I prefix for interfaces |
| Testing | Jest or Vitest, describe/it blocks, mock functions (jest.fn()), expect().toBe() assertions, .test.ts or .spec.ts co-located |
| Parameters | Options objects with destructuring, default values, rest parameters, overloaded signatures for type narrowing |
| Dependencies | Constructor injection, DI optional (tsyringe, inversify), or module-level factory functions |
| Section | Proposal summary |
|---|---|
| Error Handling | Exceptions for exceptional cases, custom exceptions from Exception base, try/catch/finally, no error codes for business logic, Result pattern growing in popularity |
| Type System | Classes, interfaces (explicit), records (C# 9+), structs (value types), nullable reference types (C# 8+), generics |
| Naming | PascalCase methods/properties/classes, camelCase local variables/parameters, _camelCase private fields, I prefix for interfaces (IService) |
| Testing | xUnit or NUnit, [Fact]/[Theory] (xUnit), [Test]/[TestCase] (NUnit), FluentAssertions, Moq for mocking |
| Parameters | Named parameters, optional parameters with defaults, builder pattern or options pattern (IOptions<T>) for config |
| Dependencies | Constructor injection via built-in DI (IServiceCollection), DI containers idiomatic, interface-first |
For languages not listed above, use open-ended questions for each section:
language and version# Language Idioms: {Language}<!-- INTERVIEW GUIDANCE: --> commentsTarget size: 40-60 lines of focused content. Each section should be 4-8 lines: a brief philosophy statement plus the key idiomatic patterns as a concise list. No code examples -- atoms have their own examples in pseudocode that they adapt using this document's guidance.
Determine output path:
.lattice/config.yaml exists and has paths.language_idioms, use that path..lattice/standards/language-idioms.md.Update config:
language: {language} at top level (create or update).paths.language_idioms pointing to the output file..lattice/config.yaml does not exist, create it. Preserve all existing content.Confirm to user:
"Your language idioms document has been written to [PATH] for [Language] [version]. The following atoms will now adapt their patterns: clean-code, test-quality, secure-coding, domain-driven-design, and architecture."
Before writing the final document, verify:
Error Handling, Type System & Object Model, Naming Conventions, Testing Patterns, Parameter & Function Design, Dependency Managementlanguage and version valueslanguage key and paths.language_idioms<!-- INTERVIEW GUIDANCE: --> comments remain in output