PitLore
Executable pit lore for coding agents.
Turn past bugs into versioned Lessons that any coding agent (Codex, Claude Code, Cursor, …) can retrieve before writing code and check before you ship.
The lore of pits your agents must not fall into again.
Brand is provisional (PitLore). Domain purchase is deferred until the project proves useful.
Why
Coding agents forget. Teams re-hit the same traps. Wiki pages are not enforceable.
PitLore is:
| Layer |
Role |
| Lesson |
One abstract anti-pattern + safer pattern (+ optional regex detectors) |
| Lore |
A local Git-friendly folder of lessons (private by default) |
| MCP / CLI |
Runtime tools every agent can call |
| Hard path |
pitlore check / CI — not only soft prompts |
See the current project status, adoption and dogfood evidence,
documentation map, and full product intent in
docs/PRD.md.
Install and quick start
PitLore requires Node.js 22+ and Git. Consumer CI is configured for the current
Node.js 22 and 24 LTS lines; the public Actions run must pass before a release.
Install from npm
The supported public release is available from the official npm registry. For a
project-local, lockfile-pinned installation:
cd your-project
npm install --save-dev pitlore@0.1.1
npx --no-install pitlore --version
npx --no-install pitlore init --name my-project
npx --no-install pitlore retrieve -i "async array iteration" -l typescript
For a global CLI or one-off invocation:
npm install --global pitlore@0.1.1
pitlore --version
npx --yes pitlore@0.1.1 --version
Install from GitHub
Use the public Git repository when testing source changes or when an exact npm version is
not available. Pin a release tag or commit SHA for reproducibility:
cd your-project
npm install --save-dev "git+https://github.com/MaxHaiCom/pitlore.git#v0.1.1"
npx --no-install pitlore --version
A Git installation intentionally runs the repository's prepare build and therefore does
not support --ignore-scripts; the packed npm artifact does. Global installation is
supported for the npm registry package or a packed tarball, not for the Git dependency
path.
Work from a source checkout
git clone https://github.com/MaxHaiCom/pitlore.git
cd pitlore
npm ci
# Use the bundled seed lore (20+ classic L1/L2 lessons)
npm run -s pitlore -- search async
npm run -s pitlore -- retrieve -i "async array iteration" -l typescript
# Scan demo fixtures
npm run -s pitlore -- check demo/fixtures/bad-foreach-async.js || test "$?" -eq 2
npm run -s pitlore -- check demo/fixtures/good-foreach-async.js # clean
# Initialize a writable lore in this project (copies seed)
npm run -s pitlore -- init --name demo-lore
npm run -s pitlore -- distill -d "Forgot to await Promise.all in batch job" --id batch-promise-all
npm run -s pitlore -- approve batch-promise-all
npm ci runs the prepare build. To inspect a locally built npm artifact:
npm pack
npm install --global ./pitlore-0.1.1.tgz
pitlore --help
npm run test:package installs the packed artifact with scripts disabled, then also
executes ordinary temporary npm exec and global-install CLI paths. The consumer CI is
configured to run the same tarball on Ubuntu, macOS, and Windows; its public Actions result
must be green before release. The artifact includes a bundled MCP stdio runtime and does
not depend on the repository's src/, tsx, existing node_modules, or a separately
installed MCP SDK. Confirm the published version and registry install with:
npm view pitlore@0.1.1 version --registry=https://registry.npmjs.org
npm install --global pitlore@0.1.1
npx --yes pitlore@0.1.1 --version
If a requested version returns E404, it has not been published to npm; use an exact
public Git ref only when that source-install path is intended. A public source commit does
not imply an npm publication. PitLore is developed in public at
MaxHaiCom/pitlore. The source repository
is public, while every local .pitlore/ store, candidate, review, and evidence ledger
remains private by default and is excluded from Git.
For a team-owned lore in a separate private Git repository:
POSIX shell:
npm run -s pitlore -- init --path ../team-lore --name your-org/your-project
PITLORE_LORE="$PWD/../team-lore" npm run -s pitlore -- search async
PowerShell uses the same CLI with its environment syntax:
npm run -s pitlore -- init --path ../team-lore --name your-org/your-project
$env:PITLORE_LORE = (Resolve-Path ../team-lore)
npm run -s pitlore -- search async
Remove-Item Env:PITLORE_LORE
CLI
| Command |
Purpose |
pitlore init |
Create ./.pitlore (--home or --path <team-lore>) |
pitlore add <file> |
Validate and store a Lesson YAML/JSON file as a candidate |
pitlore search [q] |
Search lessons; use --status rejected to audit tombstones |
pitlore get <id> |
Show lesson JSON, including an explicitly selected tombstone |
pitlore retrieve -i <intent> [-f <file> ... | --files <file> ...] |
Top-K ranked lessons + prompt block |
pitlore check <file> |
Heuristic pattern scan (exit 1 on findings, 2 if block) |
pitlore distill -d "..." |
Create candidate lesson (uses OPENAI_API_KEY if set) |
pitlore review <id> |
Print an untrusted-data packet for an LLM, or record strict review JSON with --input |
pitlore review-queue |
Show unreviewed/current/stale LLM recommendations for human review |
pitlore approve <id> |
Promote candidate → approved |
pitlore reject <id> |
Move candidate → rejected and retain a non-consumable tombstone |
pitlore deprecate <id> |
Retire a previously approved Lesson → deprecated |
pitlore evidence … |
Explicitly record local human judgments and summarize real dogfood evidence |
pitlore signal ingest|ci|sentry … |
Turn bounded resolved CI/Sentry metadata plus operator-written one-line abstractions into a private candidate; never paste raw logs/source |
pitlore export-public <id> |
Sanitize one explicitly selected approved Lesson for public export; never publishes automatically |
pitlore install <path|https-url> |
Verify, checksum, cache, and lock a public Pack (--ref pins a Git branch/tag; --subdir selects a Pack inside a repository) |
pitlore install --frozen-lockfile |
Verify every locked Pack and dependency without changing the lock |
pitlore uninstall <name> |
Remove an unneeded Pack from the lock (fails if another Pack depends on it) |
pitlore pack verify <path> |
Validate public/approved policy, detector safety, fixtures, files, and canonical SHA-256 |
pitlore pack sign <path> --private-key <key.pem> |
Add an Ed25519 signature over the canonical Pack payload |
pitlore pack list / pitlore pack verify-installed |
Inspect or fail-closed verify the effective Pack catalog |
pitlore pack artifact export|verify|install … |
Move one canonical verified Pack through an air-gapped JSON artifact |
pitlore pack artifact bundle-export|bundle-verify|bundle-install … |
Move and atomically lock one root Pack's exact dependency closure |
pitlore registry search |
Search anonymous public Registry Packs by name or verified --language / --ecosystem / --tag facets; --facets returns metadata |
pitlore registry install <name@version> |
Download, verify, cache, and lock one exact public/private Registry release |
pitlore registry sync |
Revalidate exact Registry locks and fail when a release was yanked |
pitlore registry provision-member … |
Let a verified human admin/owner pre-bind one exact OIDC subject and organization role |
pitlore registry create-package|publish|approve|reject|yank … |
Run the governed Registry publication lifecycle |
pitlore registry report-usage |
Explicitly submit one strict, privacy-safe usage event with an idempotency key |
pitlore registry migrate|bootstrap|bootstrap-token|serve … |
Operate the durable PostgreSQL self-hosted Registry |
pitlore registry reindex-discovery |
Migration-owner-only, bounded rebuild of missing discovery rows from reverified immutable artifacts |
pitlore export-agents |
Print AGENTS.md snippet |
pitlore serve |
MCP server on stdio |
pitlore path |
Print resolved lore root |
For multiple paths, either repeat --file or use the space-separated plural alias:
pitlore retrieve -i "task" --files src/a.ts src/b.ts. A comma remains part of a
literal filename; it is not a list separator.
Installed Packs use a commit-friendly pitlore.lock.yaml beside the project
.pitlore/ directory and an ignored content-addressed cache under
.pitlore/packs/sha256/. Runtime search/retrieve/check/export read only locked,
checksum-verified Packs. Pack IDs may not collide with local or other Pack Lessons.
Local Pack sources must live inside the project; remote sources must be credential-free
HTTPS Git URLs, and --subdir can select a Pack nested inside a Git repository. A Git
URL/commit/subdirectory is recorded provenance. Before parsing any Pack YAML, verification
enumerates the allowed payload, applies per-file/count/aggregate size budgets, and rejects
symlink or realpath escapes. Public Packs must carry a non-empty UTF-8 LICENSE. Signed
Packs verify Ed25519 payload integrity; embedded keys remain self-asserted unless
installation explicitly pins their fingerprint with --trust-key sha256-….
Environment:
| Var |
Meaning |
PITLORE_LORE |
Override lore root |
OPENAI_API_KEY |
Enable LLM distill |
PITLORE_MODEL / OPENAI_MODEL |
Model id (default gpt-5.6) |
PITLORE_PACK_GIT_TIMEOUT_MS |
Bound HTTPS Git clone time; 250–300000 ms (default 120000) |
PITLORE_PACK_GIT_MAX_TRANSFER_BYTES |
Fail-closed disk-growth budget for the clone; 65536–1073741824 bytes (default 64 MiB) |
PITLORE_REGISTRY_URL |
Base URL for Registry HTTP clients such as search/install/sync unless --url is used |
PITLORE_REGISTRY_TOKEN |
Optional bearer token for protected Registry operations; never commit it |
Self-hosted Registry engineering baseline
The optional Phase 3 service reuses the exact Pack artifact and lock contract above. It
ships a Fastify REST API, PostgreSQL migrations/repositories with fail-closed row-level
security on org-scoped tables, public search and exact version comparison Web UI,
tenant-isolated organizations, viewer/publisher/admin/owner RBAC,
two-independent-reviewer publication, member/token revocation, canonical audit events,
explicit privacy-safe usage aggregates, opaque cursor pagination for public and
tenant-scoped collections, yank propagation, and Docker Compose. Its nine ordered
migrations include public-release RLS (006), database-enforced append-only and approval
integrity (007), indexed SemVer keyset pagination (008), and the append-only,
RLS-protected public discovery projection (009).
Exact comparison is a bounded semantic artifact diff, not a metadata-only table. The
public /v1/public/diff endpoint fully re-verifies two published or yanked artifacts and
returns only counts, Lesson IDs, and changed field names. It never returns Lesson values,
manifest values, fixture paths, or fixture bodies; each change category returns at most
100 details and the diff JSON is capped at 128 KiB. Yanked artifacts remain comparable for
incident analysis even though direct artifact download continues to return 410.
Browser login uses an HttpOnly/Secure __Host- session cookie, a session-bound CSRF
token for unsafe requests, and Cache-Control: no-store on protected responses. Each
cookie-authenticated request resolves the exact provider/issuer/subject again and uses the
current active user, membership, and role rather than a stale login-time snapshot. Six
independent in-process rate-limit budgets isolate semantic diffs, ordinary public reads,
browser auth, billing webhooks, protected API authentication, and release uploads. Small
JSON routes, billing webhooks, and the overall request/release path are capped at 64 KiB,
256 KiB, and 30 MiB;
forwarding headers affect client identity only when PITLORE_TRUST_PROXY explicitly
allow-lists the reverse proxy.
The public package-list endpoint keeps its legacy default wire contract: each result has
exactly name, visibility, and created_at. Only include=facets (CLI --facets)
adds latest_version