Repository navigation
Generated Artifacts and Knowledge Freshness
Canonical source:
rules/24-generated-files-and-knowledge-freshness.md— this page is rendered from it on every publish; edit the source.
The AI-native workflow depends on machine-readable facts staying true. The .ai/
manifests, Prisma clients, and knowledge context are derived artifacts — if they
drift from the code, every agent that reads them makes wrong decisions. This rule
keeps generated state fresh and never hand-edited.
.ai/manifests/*.json, .ai/local/current-context.*, .ai/BOOTSTRAP.md,
.ai/packs/*.md, Prisma-generated clients, and the tools/{knowledge,audit,affected,release} tooling.
-
Never hand-edit generated files.
.ai/manifests/*, generated Prisma clients, and rendered packs are outputs — change the source, then regenerate. -
Load context before working:
npm run knowledge:context -- --task="…"writes.ai/local/current-context.md(the affected services/routes/events/i18n for your task). Read it; do not guess the blast radius. -
Regenerate after structural change. New service/route/event/env/permission/
i18n key → rebuild the knowledge base (
npm run knowledge:build) so the manifests match reality. -
Verify freshness before commit:
npm run knowledge:check/knowledge:verifymust pass — they detect manifest ⇄ code drift (hashes in.ai/manifests/hashes.json). -
Prisma clients are regenerated, not edited — schema change → migration →
prisma generate; the generated client is never patched by hand. -
Manifests are read-only inputs to reasoning, not a place to record intent —
put intent in the plan (
.claude/Integrations/…) and let generation reflect it.
- Editing a
.ai/manifests/*.jsonby hand to "fix" a value. - Committing code that changes routes/events/env without regenerating the knowledge base.
- Skipping
knowledge:contextand inferring affected services manually. - Modifying a generated Prisma client file.
# after adding a route/event/env var:
npm run knowledge:build # regenerate .ai/manifests/*
npm run knowledge:check # 0 drift vs code
# routine, before any task:
npm run knowledge:context -- --task="add workspace webhook retry"-
Knowledge check —
knowledge:check/knowledge:verifyfail on drift. - CI job — knowledge verification runs in CI; stale manifests fail the build.
- Review checklist — no hand-edits to generated artifacts.
-
.ai/BOOTSTRAP.md,.ai/manifests/hashes.json,.ai/manifests/repository.json. - Root
CLAUDE.md— Knowledge OS references.
-
knowledge:contextloaded before the task. - Knowledge base regenerated after any structural change;
knowledge:checkclean. - No generated file (manifest or Prisma client) hand-edited.
.ai/**, every workspace AGENTS.md, and
docs/features/ai-native-engineering-os/inventory.snapshot.json are
generated from the tree. CI verifies them on every push:
| CI job | Command | Fails when |
|---|---|---|
| Knowledge freshness | npm run knowledge:check |
a generated file's hash no longer matches the tree |
| Knowledge integrity | npm run knowledge:verify |
stale file, broken link, orphan reviewer, hook-bypass, contradiction |
| Inventory audit | npm run audit:check |
the inventory snapshot hash has drifted |
A stale artifact turns the build red on every subsequent push, for everyone, until someone regenerates it. It is not a warning and it is not deferrable.
The hook does this; run it by hand only to fix a red CI. pre-commit step 3
(node tools/affected/index.mjs knowledge --record) regenerates the knowledge
layer and the inventory snapshot, stages them, and runs the knowledge:verify
checks in the same pass, on every commit. There is nothing to remember and
nothing to run before committing.
When CI's knowledge-freshness or knowledge-integrity job is red (a commit
that came from somewhere the hook did not run — a rebase, a web edit, a bot),
regenerate and commit:
npm run knowledge:build # rewrites .ai/** + workspace AGENTS.md
npm run audit # rewrites the inventory snapshot
git add .ai docs/features/ai-native-engineering-os/inventory.snapshot.json
git add apps/*/AGENTS.md packages/*/AGENTS.md
npm run knowledge:verify # what CI runsThis is the mistake that actually caused a red build:
-
npm run knowledge:build— hashes the current bytes -
git add/ commit — lint-staged reformats the staged files - the reformatted bytes no longer match the hashes recorded in step 1
-
knowledge:checkpasses locally (it ran before the reformat) butknowledge:verifyfails in CI
Generators must run after prettier and eslint --fix have settled. The
pre-commit hook is ordered that way deliberately: lint-staged is step 1,
regeneration is step 3.
If a generated file is wrong, fix the generator or its input, then
regenerate. Editing .ai/manifests/*.json or a workspace AGENTS.md by hand is
overwritten on the next build and hides the real problem.
Docs that carry generated test/workspace counts (context/testing-map.md, context/workspace-map.md, docs/15-ai-context/ai-context-pack.md, the wiki pages) are rewritten by knowledge:build. The pre-commit knowledge step now stages them (ADR-202, tools/knowledge/count-fragments.mjs listFragmentDocs), so pre-push never finds a stale count; if one is still stale, git push regenerates and commits it as chore(knowledge): refresh generated files.
ClawAI Wiki · source-controlled under wiki/ · generated/mirrored from the current repository knowledge layer.
ClawAI Wiki
Product
- Product-Vision
- Flagship-Features
- Business-Overview
- Requirements-Register
- Drift-Log
- Runtime-Managed-Connector-Providers
- Threads
- ADR-Index
Architecture
- System-at-a-Glance
- Architecture-Map
- System-Architecture
- Message-Flow
- End-to-End-Data-Flow
- Routing-Engine
- Event-Bus
- Security-Architecture
Platform
- Backend-Services
- Frontend-Architecture
- Shared-Packages
- Database-Reference
- API-Reference
- Provider-Catalog
- Memory-and-Context-Architecture
- File-Support-Architecture
- Research-and-Web-Crawling
Runtime & Ops
- Docker-Guide
- Nginx-Reference
- CI-CD-Pipeline
- Logging-and-Observability
- Operational-Runbooks
- Troubleshooting
Quality
Engineering OS
- AI-Native-Engineering-OS
- Generated-Manifests
- Rules-Catalog
- Skills-Catalog
- Context-Layer
- Engineering-Memory
- Tooling-and-Automation
- Scripts-and-Operations
- ESLint-and-Architecture-Enforcement
- Extended-Work-Skills
Agents
Reference