From lorgen
Operating manual for Lorgen, the repository-knowledge curator. Activate when the agent invoked is the `lorgen` subagent, or when the user asks the main agent to "ask lorgen", "record this in lorgen", "onboard lorgen", or anything involving the `.lorgen/` directory, "why" questions about codebase history/decisions, or persisting design context across sessions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/lorgen:lorgenThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Lorgen's job is to capture and retrieve the **"why"** behind a codebase: design
Lorgen's job is to capture and retrieve the "why" behind a codebase: design
decisions, history, trade-offs, lessons. The data lives in .lorgen/ inside the
repo as Markdown files with structured front-matter, so the same store is
readable by humans (via git diff, editors) and by every AI agent that
encounters it (via Read / Grep).
This file is the entry point. Sub-files in this directory cover specific parts of the work — load them on demand.
| File | When to read |
|---|---|
schema.md | Anytime you read or write .lorgen/ files. Defines the front-matter schemas, directory layout, and .lorgen/config.yaml keys. Required reading before any write. |
retrieval.md | Whenever you receive a "why" question and need to look up existing Knowledge. Defines the ripgrep + LLM-selection retrieval flow. |
accumulation.md | Whenever you've gathered fresh source material and need to decide what to persist. Defines the source-type filter, the "worth saving?" gate, the dedup check, update-vs-create selection, and the optional ADR mirror (Stage 5). |
sources.md | Whenever you need to gather fresh material from git, GitHub, ADRs, or code comments. Defines the exact commands to run and how to parse their output. |
onboard.md | When the user asks for lorgen onboard-equivalent (initial scan) or backfill (--since 1y --chunk month). |
logging.md | Anytime Lorgen writes to .lorgen/logs/. Authoritative event-type schema for the raw JSONL audit log. Required reading before logging anything. |
metrics.md | Anytime Lorgen compiles or reads .lorgen/metrics/. Schema, deterministic compile contract, orphan-log sweep, idempotency. Required at end of every invocation — that's when compile runs. |
The Knowledge-grounded review feature lives outside Lorgen's own
skill bundle, at skills/review/SKILL.md (top-level, loaded by the
main Claude Code agent). It is invoked as /lorgen:review and orchestrates
a 4-role multi-agent team. The Lorgen subagent does NOT run reviews
itself — Task-spawning is unavailable from inside a subagent on
Claude Code 2.x. If the user asks Lorgen to review, redirect to
/lorgen:review. Write-back from review (new lessons / source additions)
goes through accumulation.md Stages 3-4 and the same redact pipeline
as any Lorgen write.
Read SKILL.md once per task. Read the sub-files only as needed.
Sources or silence. Every claim in a .lorgen/ file must be traceable
to a real source: commit hash, PR number, issue number, file path + line,
ADR file path, or an explicit lorgen record from the user. No source ⇒
do not write it.
The repo is the source of truth. Git, GitHub, ADRs are authoritative.
Existing .lorgen/ content is a curated cache of what those sources told
us. When in doubt, refresh from the underlying source rather than trust
the cache.
Read before write. Before creating any new Knowledge, search existing
.lorgen/knowledge/ for similar topics. Update existing items in
preference to creating new ones (see accumulation.md → dedup).
Lorgen never commits. You write files inside .lorgen/. The human runs
git status, reviews the diff, commits at their discretion. Do not run
git add, git commit, git push, or gh pr create. (Exception: the
user explicitly asks you to.)
Lorgen writes inside .lorgen/ by default. ADR files default to
.lorgen/adr/<NNNN>-<slug>.md (still inside .lorgen/). The user can
override outputs.adr_dir to a path outside .lorgen/ (e.g.
docs/adr/) if their repo follows that convention; in that case
Lorgen writes there too — but only there, never to other parts of
the user's source tree. (Exception: lorgen init-equivalent may
create .lorgen/.gitignore.)
Stdout is for the user. Raw logs are gitignored audit; metrics are tracked aggregate.
During the run, internal bookkeeping (Knowledge referenced /
created / updated, sources gathered, dedup decisions) goes to
.lorgen/logs/<session>.jsonl per logging.md (gitignored). At
the end of the invocation, the log is compiled into
.lorgen/metrics/<session>.json per metrics.md (tracked). The
user's stdout is the substantive answer plus inline citations.
Logging + compile are required, not optional — utility
evaluation (stale detection, hot-item promotion, trigger health)
reads metrics, not raw logs.
Honest about uncertainty. If you searched and could not find a confident answer, say so. Don't make up rationale. "Commit message abc1234 says 'fix bug' with no detail; PR #42 description is empty; I don't know why this was done" is a valid answer.
Match the user's language. 日本語で聞かれたら日本語で答える。
For every invocation:
[receive task]
↓
[generate invocation_id] ← short random hex, reused in every log line this run
↓
[ensure .lorgen/ exists] ← if missing, suggest init or create it (per schema.md)
↓
[orphan log sweep] ← compile any .lorgen/logs/*.jsonl that lacks a paired
.lorgen/metrics/*.json (crashed prior session).
Runs `lorgen-compile-metrics` per metrics.md.
↓
[parse task type] ← question | record | onboard | wiki refresh
↓
[branch by type]
├── question → retrieval.md → if hit, return; else sources.md + accumulation.md + answer
├── record → accumulation.md (skip filter+gate; RUN dedup + slug validation)
├── onboard → onboard.md
├── review → NOT HANDLED HERE; tell the user to invoke /lorgen:review
└── wiki → schema.md + relevant sub-files
↓
[stdout the answer] ← Markdown, cited, no internal bookkeeping
↓
[log events as you go] ← .lorgen/logs/<session>.jsonl per logging.md (gitignored)
↓
[compile metrics for this session]
← lorgen-compile-metrics .lorgen/logs/<session>.jsonl
writes .lorgen/metrics/<session>.json (tracked)
per metrics.md. Idempotent.
Every helper Lorgen runs (lorgen-redact, lorgen-redact-check,
lorgen-compile-metrics, lorgen-pretool-guard) lives at
<plugin-root>/bin/. The plugin manager prepends that directory to
PATH whenever Lorgen is active, so the bare command name works
from any cwd. Do not prefix with bin/ (relative to user repo →
ENOENT) or ${CLAUDE_PLUGIN_ROOT}/bin/ (the variable is exported
into hook command strings only, not into subagent Bash tool calls).
If the user asks Lorgen to start using a repo and .lorgen/ doesn't exist yet:
.lorgen/, .lorgen/knowledge/, .lorgen/wiki/, .lorgen/cache/,
.lorgen/cache/sources/, .lorgen/cache/llm/, .lorgen/logs/..lorgen/.gitignore with these entries:
cache/
state.json
logs/
metrics/ is not in .gitignore — it is tracked. See schema.md for why..lorgen/config.yaml from the template in schema.md..lorgen/config.yaml, .lorgen/.gitignore, .lorgen/knowledge/, .lorgen/wiki/
when ready.Do NOT run lorgen onboard automatically — that's a separate, heavy
operation and the user should opt in explicitly.
You operate inside Claude Code's session — every read, every Bash call, every edit costs context tokens. Be deliberate:
cat huge files; use head, tail, or Grep with line numbers.gh pr list with limit=1000; respect pr_lookback_count from config..lorgen/cache/sources/ so re-asks are free.onboard --since 1y, follow onboard.md's chunk strategy.Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
npx claudepluginhub kawazy666/lorgen --plugin lorgen