knowledge-priming-refiner

$npx mdskill add techygarg/lattice/knowledge-priming-refiner

Creates a project-specific knowledge base document for AI priming.

  • Solves the problem of AI lacking project-specific context and defaults.
  • Depends on user input and optionally .lattice/config.yaml for output path.
  • Decides content by guiding a structured conversation about tech stack and architecture.
  • Delivers a knowledge-base.md file at .lattice/standards/knowledge-base.md.

SKILL.md

.github/skills/knowledge-priming-refinerView on GitHub ↗
---
name: knowledge-priming-refiner
description: "Facilitate a structured conversation to create a project-specific knowledge base document. Produces a knowledge-base.md that primes AI with the project's tech stack, architecture, trusted sources, and project structure. Use when the user says 'set up knowledge base', 'prime the project', 'onboard AI', 'create knowledge base', 'set up project context', or 'configure AI context'."
---

# 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, create it with `paths.knowledge_base` pointing to the output file.
2. If it exists but lacks the key, add it. Preserve existing content.

## Document Quality Checks

Before writing the final document, verify:

- [ ] Content is specific, not generic ("Fastify 4.x" not "modern framework")
- [ ] Tech stack entries include version numbers where applicable
- [ ] "Not X" clarifications steer AI away from common defaults that do not apply
- [ ] Curated sources are limited to 5-10 high-value entries
- [ ] No coding guidelines (naming rules, code examples, anti-patterns) -- those belong in other skills
- [ ] Document stays under ~50 lines of focused content (excluding headings and formatting)
- [ ] Would a new developer find this useful for understanding *what this project is*?
- [ ] **Not a redirect stub** — fewer than 3 of the 5 sections populated, or body primarily points to another file → STOP before writing. Say: "This knowledge base is mostly a pointer and won't prime sessions effectively. Should we inline the key content from [referenced file] instead?" Do not write a redirect-only document.

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.