Rassam
AGENTS.md20 starsChanged 5 days agoApache-2.0View on GitHub
Read this before making changes. Rassam is checked against its own architecture contract, .rassam/blueprint.json. If you are a coding agent, the rassam MCP server in .mcp.json answers the questions below for you: call explain_path before editing a file, check_dependency before adding an import, check_changes before you finish, and report_conflict instead of weakening a test, a check or the blueprint. Rassam is the architecture contract for agent-built software. It has four parts that share one isomorphic engine:
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
The file
We split this agents.md into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 47
Only new violations fail a change.
- Very specific: line 87
Every route validates its body with zod (src/lib/api-request.ts, src/lib/contracts.ts), goes through guardApiRequest in …
- Very specific: line 108
Add the phrase to the deterministic parser in src/blueprint/intent.ts and its tests.
- Very specific: line 112
Add the icon and colour to src/components/blueprint/kinds.ts.
- Very specific: line 115
If OpenAI-compatible: extend OpenAICompatibleAdapter from src/lib/llm/providers/OpenAICompatibleAdapter.ts.
- Very specific: line 123
Ensure these are set in .env.local for local development:
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rassam - Agent Guide
Read this before making changes. Rassam is checked against its own architecture contract, .rassam/blueprint.json. If you are a coding agent, the rassam MCP server in .mcp.json answers the questions below for you: call explain_path before editing a file, check_dependency before adding an import, check_changes before you finish, and report_conflict instead of weakening a test, a check or the blueprint.
Project Overview
Rassam is the architecture contract for agent-built software. It has four parts that share one isomorphic engine:
- The blueprint (
.rassam/blueprint.json, spec indocs/blueprint-spec.md, schema insrc/blueprint/schema.ts): components and the files they own, human-written intent, declared dependencies, rules, invariants, decisions and sign-offs. - The engine (
src/blueprint/): import graph, component membership, rule evaluation, the change gate, reach analysis and report rendering. It must stay isomorphic: nonode:imports, no DOM, no React/Next, no imports from the rest of the app. Onlyzod. - The Node host (
src/cli/): therassamCLI, git and GitHub Actions integration, and the dual-era MCP server. Bundled toaction/dist/rassam.mjs(npm run build:cli; CI checks the bundle is fresh). The same bundle is the npm package@v0ightt/rassam(packages/rassam/, staged bynpm run pack:cli, published only by.github/workflows/release.ymlon a version tag; seedocs/releasing.md).PACKAGE_NAMEandENGINE_VERSIONinsrc/blueprint/constants.tsmust match the package manifest (a test enforces it). - The Studio (Next.js app at
/): one screen that answers "is the project on track?" for a local folder or a public GitHub repository (src/components/studio/,src/components/blueprint/,src/components/ui/,src/hooks/useBlueprint.ts,src/lib/blueprint-client/,src/lib/blueprint-intent/,src/app/api/blueprint/**,src/app/api/live/**), plus a settings page for the optional model.
Engine module map (src/blueprint/)
| Module | Responsibility |
schema.ts | Blueprint v0.1 zod schema, parse/validate/serialize, JSON Schema |
types.ts, constants.ts | Shared engine types; ignore globs, test patterns, built-in tripwires |
glob.ts, paths.ts, util.ts | Isomorphic glob matcher, POSIX paths, hashing |
imports.ts | Multi-language import extraction and resolution → FileGraph |
env.ts, reach.ts | Env/secret reads; agent configs, MCP servers, permissions, inline secrets |
selectors.ts, graph.ts | Selector grammar; component membership, component graph, cycles |
rules.ts, stats.ts, impact.ts | Rule and policy evaluation; human-authored ratio; blast radius |
diff.ts, blueprint-diff.ts, agents.ts | Unified diff parsing, tripwires, verification-weakening heuristics; semantic contract diff; agent authorship |
check.ts | runCheck: full and diff mode, base-contract judging, new-vs-existing, scoring |
workspace.ts | Query layer for MCP/CLI/canvas: explainPath, checkDependency, impact, componentSummary, overview, graphView (cards with finding counts and worst severity; a dependency cycle is reported once in cycles and on its edges, never as a badge on every member) |
derive.ts, verify.ts, snapshot.ts | Draft blueprints (rassam init); sign-off stamps; compact graph transport |
prose.ts | The contract as plain-language rules for AGENTS.md (the block between <!-- rassam:agents:start --> and <!-- rassam:agents:end -->); pure and deterministic, so a stale block is found by regenerating it |
report.ts | Text, Markdown sticky comment, SARIF, GitHub annotations, JSON, Mermaid, DOT |
Node host map (src/cli/)
| Module | Responsibility |
main.ts, args.ts, io.ts | Dispatch, flags and help, process seams (Io.ask exists only in an interactive terminal; commands must work without it) |
commands/init.ts | Draft the blueprint, report drafted rules the code already breaks ("existed before the contract did"), then offer the wiring below |
agent-files.ts | Idempotent writers for .mcp.json, the AGENTS.md block, the CLAUDE.md pointer and .github/workflows/rassam.yml; never touch text outside their markers or overwrite a person's own settings |
commands/instructions.ts | rassam instructions (--write, --check): keep the AGENTS.md block in step with the contract |
gate.ts, commands/check.ts | Assemble the change (git, merge-base, base blueprint) and run the engine; check also notes a stale AGENTS.md block |
mcp/ | The MCP server and its tools |
Non-negotiable behaviors
- A change is judged by the base blueprint. Contract-weakening edits are errors until a human applies the approval label. Invariant commands run only from the base blueprint.
- Under the default
policy.verificationWeakening: "require-approval", the strong verification-weakening signals (skipped or focused tests, removed or trivialized assertions, deleted test files, lowered or removed coverage thresholds, forced success exits; the split isWEAKENING_SIGNALSindiff.ts) are errors until a human applies the same label. Weak signals and the generic test tripwire stay warnings, and no negative case inbench/gatemay fail. - Only new violations fail a change; fingerprints must stay stable (no line numbers in fingerprints).
- Static analysis is the only source of dependency edges. LLM output never becomes a blueprint fact without human acceptance, and agent proposals go to
.rassam/proposals/, never intoblueprint.json. - Secrets are never printed: reports carry redacted previews only.
Working on the blueprint itself
- Changes to architecture should be reflected in
.rassam/blueprint.jsonin the same change (new components, paths, declared dependencies). Runnpm run rassam -- check(full) andnpm run rassam -- check --base main(as CI does). - Edits that weaken rules need a human-approved label on the PR. Do not loosen a rule to make your change pass; use
report_conflictand explain.
The Studio (web app)
Tech stack
- Framework: Next.js 16 (App Router), React 19, TypeScript
- Styling: Tailwind CSS v4 with design tokens in
src/app/globals.css(dark and light themes, iris accent) - Canvas: React Flow, with dagre for components that have no saved position
- Browser storage: Dexie (IndexedDB database
rassam-blueprints) for drafts, layout and folder handles; localStorage for preferences - GitHub: Octokit, public repositories only, always at a pinned commit
- AI (optional): provider adapters for DeepSeek, OpenAI, Anthropic, Google and Ollama, used only by "tell Rassam what to change" when the built-in parser does not understand a request
How a session flows
- Open a source (
StartScreen.tsx,useSourceActions.ts): paste a GitHub URL, open a local folder, or try the bundled sample (sample.ts).- GitHub:
POST /api/blueprint/openresolves the repository to a pinned commit and returns a signed source grant;POST /api/blueprintdownloads that commit, builds the engine's file graph and returns a compact snapshot plus the repository's.rassam/blueprint.json(or nothing, and the browser derives a draft). - Local folder:
src/lib/blueprint-client/local-folder.tsreads the folder through the File System Access API; analysis runs insrc/workers/blueprint-analysis.worker.ts. Files never leave the machine.
- GitHub:
- Check (
src/hooks/useBlueprint.ts): the hook owns the session. It runs the engine against the draft on every edit, so findings, health and reach update instantly. - Read (
Studio.tsx): five persistent elements only: source pill, health pill, canvas, intent bar, zoom cluster. Sheets (AttentionSheet.tsx,SourceSheet.tsx) and the inspector open on demand. - Change: the intent bar parses the sentence in the browser with the deterministic parser (
src/blueprint/intent.ts). Only when the parser does not understand, and a model is selected in Settings,POST /api/blueprint/editasks that exact provider and model (src/lib/blueprint-intent/: prompt building, tolerant JSON extraction, schema validation, dry run). Every change becomes a proposal drawn on the canvas (ProposalCard.tsx); nothing touches the draft until the person applies it, and every applied change is one undo step. - Save: local folders are written back into the repository (
.rassam/blueprint.json, layout in a separate file); GitHub projects download the file. - Stay live:
POST /api/blueprint/commitsfeeds the commit timeline and the optional watch;/api/live/{owner}/{repo}/badge.svgandsystem.svgserve the README badge and diagram.
Key directories and files
src/app
page.tsx: mounts the Studio client-side. Thin wiring only.settings/page.tsx: provider and model selection for the optional model path. ReadsGET /api/settings/models; "Test model" posts the exact selection.layout.tsx,globals.css: fonts, theme boot script, design tokens.api/blueprint/**:open, the snapshot route,commits,edit.api/live/**: badge and system-design SVGs.api/settings/models,api/health,api/readiness.- Every route validates its body with zod (
src/lib/api-request.ts,src/lib/contracts.ts), goes throughguardApiRequestinsrc/lib/request-security.ts, and answers errors with the JSON envelope fromsrc/lib/api-error.ts.
src/components
studio/: the screen itself (see the flow above).commands.tsis the ">" command list of the intent bar;health.tsandproposal.tsare pure helpers.blueprint/: the canvas (BlueprintCanvas.tsx,BlueprintNode.tsx,BlueprintEdge.tsx,useBlueprintCanvas.ts), the inspector, and the manual editors behind progressive disclosure (ComponentsTab,RulesTab,IntentTab,ReachTab,AttentionTab).kinds.tsmaps well-known component kinds to an icon and colour.session.tsis the contract these components code against;useBlueprintimplements it.ui/: the design system (buttons, sheets, popovers, pills, status glyphs, toasts, theme). It depends on nothing else in the app. Status is never shown by colour alone.
src/hooks
useBlueprint.ts: session state: source, draft, history, proposals, receipts, live status, sync.
src/lib
blueprint-client/: browser host for the engine (API clients, local folder access, drafts, layout, worker bridge).blueprint-intent/: prompt and answer handling for the model path. Pure text in, typed edits out; it never calls a provider.github.ts,source-grant.ts: the only code that talks to GitHub and holdsGITHUB_TOKEN; signed grants bind repository and commit.llm/: provider catalog, registry and adapters.chat-runtime.tsresolves exactly the requested provider and model, with no silent fallback.model-settings.ts: the saved provider/model choice in localStorage. No credentials.request-security.ts,api-error.ts,api-request.ts,operational-telemetry.ts,src/proxy.ts: rate limits, sessions, origin checks, error envelope, privacy-bounded telemetry.
Common tasks
Teaching the intent bar a new sentence
- Add the phrase to the deterministic parser in
src/blueprint/intent.tsand its tests. Prefer this over prompt changes: the common commands must work with no model. - A new edit operation goes into
src/blueprint/edits.ts; keepEDIT_OP_CATALOGUEinsrc/lib/blueprint-intent/prompt.tsin step (a test enforces it).
Adding a component kind
- Add the icon and colour to
src/components/blueprint/kinds.ts. Kinds are free-form slugs; unknown ones fall back to the default.
Adding an LLM provider
- If OpenAI-compatible: extend
OpenAICompatibleAdapterfromsrc/lib/llm/providers/OpenAICompatibleAdapter.ts. Override onlyproviderId,defaultModel,apiKey, andbaseURL. - Otherwise implement the
LLMProviderinterface fromsrc/lib/llm/types.tsdirectly (seeAnthropicAdapter.ts). - Register the adapter in
src/lib/llm/registry.tsand add its metadata tosrc/lib/llm/catalog.ts.
Adding an API route
- Validate the body with zod, call
guardApiRequestwith a quota scope, return errors throughtoSafeApiError, and add the route under theapicomponent's rules (it already ownssrc/app/api/**).
Environment Variables
Ensure these are set in .env.local for local development:
DEEPSEEK_API_KEY: Required when using the DeepSeek provider.OPENAI_API_KEY: Required when using the OpenAI provider.ANTHROPIC_API_KEY: Required when using the Anthropic provider.GOOGLE_API_KEY: Required when using the Google provider.OLLAMA_BASE_URL: Optional, defaults tohttp://localhost:11434/v1.OLLAMA_API_KEY: Optional; set only when the Ollama endpoint requires it.GITHUB_TOKEN: Recommended to avoid rate limits when opening repositories. Hosted deployments must use a public-repository-only token.SOURCE_GRANT_SECRET,SESSION_SIGNING_SECRET,UPSTASH_REDIS_REST_URL,UPSTASH_REDIS_REST_TOKEN: required by the public production profile (seedocs/deployment.md).
<!-- BEGIN:nextjs-agent-rules -->This is NOT the Next.js you know
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in node_modules/next/dist/docs/ (resolved from this file's directory; in monorepos the next package may not be visible from the repo root) before writing any code. Heed deprecation notices.
This block is written and re-added by next dev — verify at node_modules/next/dist/server/lib/generate-agent-files.js. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean.
<!-- END:nextjs-agent-rules -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

