<!-- AGENTS.md at a961efe7d646cb70cbfae04e1cfde3a31fbe086c · https://github.com/OmarAlex24/everdoc/blob/a961efe7d646cb70cbfae04e1cfde3a31fbe086c/AGENTS.md · status: fresh -->

# AGENTS.md

Instructions for coding agents working in this repository. Humans: the same rules, with more context,
are in [CONTRIBUTING.md](CONTRIBUTING.md).

Everdoc compiles a repository into an architecture atlas (static site, `llms.txt`, Markdown, MCP data)
by static analysis. Its output is trusted because it is reproducible. Every rule below protects that.

## Hard constraints

1. **Determinism.** The same commit and config produce byte-identical `snapshot.json`, Markdown, and
   `llms.txt`. No wall-clock time, randomness, unordered map or set iteration, locale-dependent sorting,
   or absolute machine paths in any output. Sort everything that reaches an output explicitly, in
   code-point order; serialize snapshots with `canonicalStringify` from `@everdoc/ir`.
2. **No LLM by default.** `llm.mode: "off"` is the default, and with `mode: "surgical"` but no API key,
   summaries are skipped. Every feature must work, and be tested, with no model and no network. AI
   summaries are an optional overlay keyed by content hash; nothing else may depend on them.
3. **No repository-specific code.** Never name, special-case, or tune for a specific repository in
   `packages/*/src`, including the showcases and Everdoc itself. Recognize framework APIs, not project
   names or paths. A test scans every `src` tree for showcase names. Fixtures use invented `acme`-style
   projects.
4. **Layering.** `@everdoc/ir` has zero runtime dependencies. Packages depend only on lower layers:
   `ir → sdk, diff, llms → engine, extractors-*, mcp, summarize → site → cli`. Extractor packs stay
   generic recognizers.
5. **Page weight.** On the T3 Code benchmark, keep `/` and `/<channel>/architecture` under 100 KB of
   HTML and `/<channel>/flows` and `/<channel>/reference/env` under 80 KB. Datasets go to
   `/<channel>/data/*.json` and load on demand; never inline them in island props. Repeated styling
   goes into `packages/site/src/styles` as a shared class, not as long utility strings on every row.
   Anything added to `Layout.astro` lands on every page, so it costs bytes on all ~1,000 of them.
6. **Secrets.** Tokens never reach snapshots, HTML, Markdown, logs, error messages, or `.git/config`.
   Read them from the environment variable the config names; pass them to git through `GIT_CONFIG_*`
   environment entries, never on a command line.
7. **Honest output.** When something cannot be resolved statically, emit less (a partial flow, a
   diagnostic), never a guessed entity, edge, or description.

## Working in the code

- Extend the existing owner of a concern before adding a new module; when you replace a code path,
  migrate its callers and delete the old one in the same change.
- Islands (`packages/site/src/islands`) hydrate in the browser and ship JavaScript; views
  (`packages/site/src/views`) render to HTML only. Prefer views.
- Markdown for agents is rendered by `@everdoc/llms` and shared by the CLI, the site, and the MCP
  server. Change it there, once.
- New config options go through `@everdoc/sdk`: the type, validation with a precise issue message,
  the resolved default, and a test.

## Required verification before a pull request

Run all of these from the repository root, and wait for each to finish:

```sh
pnpm build
pnpm typecheck
pnpm test
pnpm pack:check
```

For any change under `packages/site`, also build a real atlas, serve it, and check it in a headless
browser: zero console errors, zero page errors, zero failed requests, and screenshots of the changed
pages in light and dark themes (and at a mobile width when layout changed). Check the HTML size of the
budgeted pages above when you touch the layout or a page they render.

Report what you ran and what you saw. If a check could not run, say so; do not describe it as passing.

## Pull requests

- Conventional commits: `feat:`, `fix:`, `perf:`, `refactor:`, `test:`, `docs:`, `ci:`, `chore:`,
  with the package as scope (`feat(site): …`).
- One focused change per pull request, with tests for new behavior and a failing-first test for bugs.
- Fill in the pull request template, including screenshots for UI changes. Tick only the checks you ran.
- The Everdoc PR check comments on every pull request with the structural diff (APIs, env vars, CLI
  flags, layer violations, docs drift). Explain any breaking change it reports.
