knowledge-priming-refiner
Knowledge Priming Refiner guides users through a structured interview to build a project-specific knowledge base document that captures tech stack, architecture, directory structure, and trusted sources. Use it when onboarding AI to a codebase or establishing project context, ensuring AI avoids generic patterns by understanding the specific frameworks, versions, and conventions unique to that project.
git clone --depth 1 https://github.com/techygarg/lattice /tmp/knowledge-priming-refiner && cp -r /tmp/knowledge-priming-refiner/skills/refiners/knowledge-priming-refiner ~/.claude/skills/knowledge-priming-refinerSKILL.md
# Knowledge Priming Refiner ## Purpose This refiner facilitates a structured conversation to create a project-specific knowledge base document. The document captures the project's identity -- its tech stack, architecture, directory layout, and the trusted sources that shaped how the team works. Think of it as answering one question: "What does AI need to know about *this project* to avoid defaulting to generic internet patterns?" This is not about how to write good code -- that is handled by the `clean-code` atom (coding principles), `architecture` atom (structural rules), and `domain-driven-design` atom (domain modeling). Knowledge priming covers what those skills cannot know: which framework, which version, which docs to trust, and how the repo is organized. ## What This Produces - **Output**: `.lattice/standards/knowledge-base.md` (or custom path from `.lattice/config.yaml` -> `paths.knowledge_base`) - **Mode**: Override is the standard approach -- every project's knowledge base is unique, so there are no generic defaults to overlay on. Overlay mode is available for selective revisions of an existing document. - **Config key**: `paths.knowledge_base` in `.lattice/config.yaml` - **Template**: Read `./assets/template.md` for the full document structure and interview guidance comments - **Consumed by**: The `knowledge-priming` atom loads this document via config resolution and provides it as ambient project context to all skills and molecules ## Scope Boundary Knowledge priming captures **project identity and technical context**. It deliberately excludes concerns covered by other skills: | Concern | Where It Belongs | Not In Knowledge Priming | |---------|-----------------|--------------------------| | Language idioms (error handling, type system, naming, testing patterns, DI) | `language-idioms` document | No language-level patterns or idioms | | Coding style, naming principles, function design | `clean-code` atom | No code examples, no naming rules | | Architectural layers, dependency direction | `architecture` atom | No structural rules | | Domain modeling, aggregate design | `domain-driven-design` atom | No DDD patterns | | Code-level anti-patterns (god functions, deep nesting) | `clean-code` atom | No coding anti-patterns | If you find yourself writing content that teaches *how to write code*, it belongs in one of the atoms above, not here. Knowledge priming answers "what are we working with?" -- not "how should we write?" ## Before You Begin ### Check for existing documents Before starting the interview: 1. Read `.lattice/config.yaml` -- does `paths.knowledge_base` point to a file? 2. If yes, read that file. Ask the user: - "You already have a knowledge base document. Would you like to **revise** it (update specific sections), **start fresh** (new interview), or **add to it**?" - Revise: Load the existing document, walk through only the sections the user wants to change. - Start fresh: Proceed with the full interview flow below. 3. If no config or no existing document, proceed with the full interview flow. ### Scan the repository Look for signals that inform the conversation: - **package.json / Cargo.toml / go.mod / pyproject.toml**: What languages, frameworks, and versions are in use? - **Directory structure**: How is the project organized? Monorepo, single app, modules? - **Existing docs**: README, ADRs, contributing guides, architecture docs? - **Config files**: Linter configs, formatter configs, CI pipeline files -- these reveal conventions. Share relevant findings with the user at the start: "I noticed your project uses [X framework] with [Y structure]. I'll use that as context for our conversation." ## Facilitation Approach - **One section at a time.** Walk through the 5 sections sequentially. - **Show examples first.** For each section, explain what it captures, show a concrete example, then ask the user. - **Record the user's content, not the discussion.** The output document reads as a reference. - **Encourage specificity.** "Fastify 4.x" is useful; "modern framework" is not. Version numbers matter because APIs change between versions. - **Keep it lean.** Target under 3 pages / ~50 lines of focused content. Every token competes for context window space. ## Section-by-Section Interview Guide Read `./assets/template.md` and follow the `<!-- INTERVIEW GUIDANCE: -->` comments for each section. ### The 5 sections | # | Section | What It Captures | |---|---------|-----------------| | 1 | **Architecture Overview** | Big picture: what kind of application, major components, how they interact | | 2 | **Tech Stack and Versions** | Specific technologies with version numbers, including "not X" clarifications | | 3 | **Curated Knowledge Sources** | Official docs, trusted blogs, internal references the team relies on (5-10 max) | | 4 | **Project Structure** | Directory layout showing where things live | | 5 | **Project Conventions** | Brief project-specific conventions that other skills cannot infer (optional, slim) | ### Cross-section awareness | Described in | Informs | How | |-------------|---------|-----| | §1 -- Architecture | §4 -- Project Structure | Architecture style shapes directory layout | | §2 -- Tech Stack | §5 -- Project Conventions | Stack choices may imply project-specific conventions | | §2 -- Tech Stack | §3 -- Curated Sources | Each technology has authoritative docs worth curating | ## Output Assembly 1. YAML frontmatter: `mode: override` (or `overlay` for selective) 2. Preamble text (from template) 3. All sections with the user's content 4. Sections the user skipped get a `<!-- TODO: Fill in during next revision -->` comment 5. Strip all `<!-- INTERVIEW GUIDANCE: -->` comments from the output **Determine output path:** 1. If `.lattice/config.yaml` exists and has `paths.knowledge_base`, use that path. 2. Otherwise, default to `.lattice/standards/knowledge-base.md`. **Update config:** 1. If `.lattice/config.yaml` does not exist, c
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.
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.
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.
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.
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'.
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'.
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.
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'.