nanace
AGENTS.md4 starsChanged 38 days agoApache-2.0View on GitHub
This file holds repository-wide rules. Use the nearest subdirectory AGENTS.md for path-specific invariants. nanace is a multi-tenant markdown knowledge base: Rust (Actix-web) backend, PostgreSQL for metadata, RBAC and canonical content, Qdrant for semantic search, local bge-small-en-v1.5 embeddings, a stdio MCP server (nanace-mcp) that gives Claude read access through the REST API, and nanace-p2p, through which agents of a team message each other. Read ARCHITECTURE.md for the design, data model, flows, and which parts are built or planned. Nested instructions add…
- 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 35,117 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 repository4 other files it gives its agents.
- adversarial-validationSkill
- issue-triageSkill
- pr-reviewSkill
- security-advisory-lessonsSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
20 rules. About 1 is common, 9 are distinctive, and 10 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 11
Read ARCHITECTURE.md for the design, data model, flows, and which parts are built or planned.
- Distinctive: line 34
Do not load every skill or inspect unrelated modules preemptively.
- Distinctive: line 39
Search for relevant symbols/headings before reading long files.
- Distinctive: line 59
Read only the reference needed for the current task:
- Distinctive: line 61
Before code changes, read implementation rules.
- Distinctive: line 62
Before commits, pushes, PR creation/updates, or posting to PRs/issues, read Git and PR rules.
- Very specific: line 76
Do not commit one-shot plans, trackers, or agent scratch notes.
- Very specific: line 94
Never weaken a gate to get green: do not suppress lints, ignore tests, or relax assertions unless changing that policy is itself the task.
- Very specific: line 121
Never commit secrets, credentials, or key material.
- Very specific: line 130
Every handler authenticates with AuthUser and checks access through crate::access before touching tenant data.
- Very specific: line 132
Every query that reads or writes contexts runs inside db::scoped_tx.
- Very specific: line 135
Every query on p2p_peers or p2p_presence runs inside db::scoped_tx, db::user_tx (the caller's own peers and lookups across their teams) or …
- Distinctive: line 153
Never return Qdrant payload content without that check.
- Very specific: line 156
Every state change, and every content read, writes an audit_logs row in the same transaction as the change.
- Common: line 181
Only the supervisor role of the daemon's local socket answers consent prompts and changes settings.
- Distinctive: line 220
Never edit an applied migration (checksums are verified at startup).
- Very specific: line 231
Put stable fields first (event, component, then context such as ids) and a short message last.
- Very specific: line 233
Use error for behavior/security failure, warn for degradation/fallback, info for low-frequency lifecycle, debug/trace for diagnostics.
- Very specific: line 235
Never log secrets, tokens, database URLs, context content, search queries, or raw request bodies, including through error strings and Debug …
- Distinctive: line 240
Before editing, locate nearer instructions with:
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 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
nanace Agent Instructions
This file holds repository-wide rules. Use the nearest subdirectory
AGENTS.md for path-specific invariants.
nanace is a multi-tenant markdown knowledge base: Rust (Actix-web) backend,
PostgreSQL for metadata, RBAC and canonical content, Qdrant for semantic
search, local bge-small-en-v1.5 embeddings, a stdio MCP server
(nanace-mcp) that gives Claude read access through the REST API, and
nanace-p2p, through which agents of a team message each other.
Read ARCHITECTURE.md for the design, data model, flows, and
which parts are built or planned.
Precedence
- System/developer instructions.
- The current user request.
- Applicable
AGENTS.mdfiles, with the nearest file winning conflicts. - Selected skills and reference documents.
Nested instructions add to ancestor rules; they do not discard non-conflicting rules. A skill cannot expand the user's requested scope or grant authorization.
Operating Model
- Inquiry, diagnosis, review, and planning tasks are read-only unless the user explicitly requests changes.
- Ordinary diff/commit reviews use the finding standard below directly. PR and high-risk reviews keep their workflows.
- For implementation, read the relevant code, tests, and local guidance, then make the smallest change that satisfies the request.
- State assumptions only when they affect behavior or verification. Ask only when a wrong assumption would materially change the result.
- Do not load every skill or inspect unrelated modules preemptively. Select a skill only when its description directly matches the request or changed surface.
- Resolve repository workflow skills under
.agents/skills/when a global skill has the same name, unless the user explicitly selects another path. - Search for relevant symbols/headings before reading long files. Avoid repeated reads and equivalent verification commands once enough evidence exists.
- Reuse authorization already given in the conversation. Retain explicit merge and release gates.
Common Commands
make deps # start PostgreSQL + Qdrant (docker compose)
make check # fmt check + clippy -D warnings + unit tests
make test-integration # API, RLS, MCP and P2P tests (nanace_test DB + qdrant-test)
make test-model # real bge-small model test (downloads ~130 MB once)
make run # run the API with .env (copy from .env.example)
make desktop-check # desktop app: tsc, vitest, Tauri clippy + tests
cargo test -p <crate> # test one crateTask-Specific Guidance
Read only the reference needed for the current task:
- Before code changes, read implementation rules.
- Before commits, pushes, PR creation/updates, or posting to PRs/issues, read Git and PR rules. A reference does not authorize posting, merging, or publishing.
- Preserve unrelated work.
- Source comments, commits, PR titles, and PR bodies are in English.
Sources of Truth
- Design and data model:
ARCHITECTURE.md. - Workspace membership:
Cargo.toml. - Database schema and RLS policies:
crates/nanace-server/migrations/. - Local gates:
Makefile. - Agent skills:
.agents/skills/*/SKILL.md(.claude/skillslinks here).
Do not commit one-shot plans, trackers, or agent scratch notes. Durable design
changes belong in ARCHITECTURE.md.
Verification
Select checks from the final task-owned diff.
- Docs, comments, agent instructions:
git diff --check. Skip Cargo. - Localized behavior change:
cargo fmt --all --check, the narrowest test that exercises the change, and Clippy for the touched crate. - Database, authorization, tenancy, or vector-store changes: also run
make test-integration. These tests must connect as a non-superuser role, or RLS is not exercised. - Embedding or chunking changes: also run
make test-modelwhen the real model's behavior matters. - Broad cross-crate changes:
make checkplus the integration tests. - Desktop app (
apps/desktop):make desktop-check.
Never weaken a gate to get green: do not suppress lints, ignore tests, or relax
assertions unless changing that policy is itself the task. Integration tests
are #[ignore] only because they need external services; run them with
--ignored.
Adversarial Validation
Adversarial validation applies to final implementation diffs, explicitly requested adversarial/design reviews, and agent-instruction changes that alter execution. Ordinary questions, diagnoses, status reports, non-adversarial code reviews, and low-risk planning do not trigger it.
For applicable work and substantial PR reviews, read the risk tiers and review shape.
A review has no finding quota; No findings is a complete outcome. Before
reporting a candidate, check callers, invariants, and existing tests for
evidence that disproves it. Findings need file:line and a concrete failure or
violation of an explicit requirement. Missing tests are verification gaps, not
proof of a runtime bug. Keep style preferences out of defect findings unless
that review was requested.
Fix or rebut supported findings within the authorized scope, then stop. Reopen only for changed code, new evidence, or an explicit re-review request.
Security Baseline
- Never commit secrets, credentials, or key material. Configuration comes from
environment variables; secrets are held in
secrecy::SecretString. - Untrusted JSON bodies use
#[serde(deny_unknown_fields)]and are validated throughnanace_core::validateat the API boundary. - Fail closed: authorization errors deny; unknown roles are errors, not defaults.
Tenancy and Authorization Invariants
- Every handler authenticates with
AuthUserand checks access throughcrate::accessbefore touching tenant data. - Every query that reads or writes
contextsruns insidedb::scoped_tx. Do not grantBYPASSRLS, connect the app as a superuser, or add policies for roles other thannanace_tenant. - Every query on
p2p_peersorp2p_presenceruns insidedb::scoped_tx,db::user_tx(the caller's own peers and lookups across their teams) ordb::p2p_system_tx; the same goes forp2p_policiesandp2p_exchanges. The system scope is for the server's own maintenance and the node's allow list only: never open it for a request's caller, and do not widen what its policies allow beyond reading the P2P tables, deleting expired presence and deleting exchange reports past retention. - Return
404(not403) for org, team, context, or peer ids the caller cannot read, so ids cannot be probed. - Org admins manage membership but get no implicit access to team content.
- Pages titled
Policy:orWiki:(nanace_core::validate::is_protected_title) are written only by an admin of their team. Every handler that creates, updates, trashes, restores or purges a context callscontexts::require_title_access, and the RLS policies repeat the rule. Change the Rust and SQL title checks together; both runPROTECTED_TITLE_CASES. - Qdrant searches always filter on
org_idand on team ids derived from PostgreSQL, and every hit is re-checked in PostgreSQL before it is returned. Never return Qdrant payload content without that check. - One Qdrant collection per org (
vectors::collection_name); never query across collections. - Every state change, and every content read, writes an
audit_logsrow in the same transaction as the change. nanace-mcptalks only to the REST API as the configured user and, for thep2p_*tools, to that user'snanace-p2pdaemon over its local socket; it never gets database or Qdrant credentials, the peer key or the daemon's token, and it links no networking code (nanace-p2pwithdefault-features = false). Thep2p_*tools are registered only withNANACE_ALLOW_P2P=trueand a reachable daemon. Text from a peer is returned throughp2p::peer_message, never raw. Write tools (create_context,update_context) are registered only withNANACE_ALLOW_WRITES=trueand need a write-scoped token; there is no delete tool. Tools never take tenant scope from context content. stdout is the MCP channel: log to stderr only.nanace-p2p: the node has no database, token or message and learns only the allow list from the internal listener; never expose that listener publicly or serve anything else on it. A daemon takes identity, team roles and policy from the registry, never from a peer. Every check inDaemon::receive_requestruns before a message is stored or shown; do not add a path that skips them or that executes anything on behalf of a message. Message text is never logged, reported to the server or put in an error. The built-in secret rules cannot be disabled by a policy. Received requests are stored only within the caps at the top ofdaemon.rs, and a record's text is cleared when its side of the exchange ends; do not add a state that keeps text longer. Lookups caused by peers the node or a daemon does not know stay behind aThrottle.- Only the supervisor role of the daemon's local socket answers consent prompts and changes settings; its secret is never written to disk.
- JWTs and personal access tokens identify the user only. Never put roles or team ids in tokens; permissions are read from PostgreSQL per request.
- Handlers that change state take
WriteUser(rejectsread-scoped tokens); read-only handlers takeAuthUser. Both rejectp2p-scoped tokens. Only peer-registry handlers,GET /meand a token rotating or revoking itself takePeerUser/AnyScopeUser; never use those for a handler that reads or writes pages. The one page text ap2ptoken reaches is the guidance of its team'sPolicy: P2P(get_policywithtext=true), which the daemon hands to agents; do not add another. - The team role
agentedits only contexts it created and never deletes: create and update checkTeamRole::Agentpluscontexts::require_title_access; everything else that writes keeps requiringTeamRole::Writer. Token management requiresAuthUser::require_session. - Store only hashes of tokens and login codes; never log or return a secret after creation. Session tokens never go in URLs.
- The desktop app runs
nanace-p2pas a sidecar it spawns from Rust (no shell permission for the webview). The webview reaches the daemon only throughp2p_calland the method list inp2p.rs::WEBVIEW_METHODS; never add agent-side methods (ask,reply,inbox) to it. The peer key lives in the OS keychain and the daemon'sp2p-scoped token in a 0600 file; neither reaches the webview. - The desktop webview never sees tokens: API calls go through the Tauri
apicommand, which only reaches<server>/api/v1/. Do not add Tauri permissions or commands that expose HTTP, the filesystem, or the shell to the webview, and keep/api/v1/me/tokens*and/api/v1/auth/*out of theapiproxy. The one file read isscan_claude_memory: fixed to~/.claude/projects/*/memory/*.md, no symlinks, size-capped. The one config write is "Connect to Claude":claude mcp add/remove --scope user(the CLI, never editing~/.claude.jsondirectly) and a merge of thenanaceentry in Claude Desktop's config, pointing at a 0600 token file (NANACE_TOKEN_FILE); never put a token in a config or on a command line. GoogleOAuth::with_token_urlexists for tests: the ID token signature is not checked, so production must use Google's HTTPS token endpoint.
Schema and Upgrades
- Never edit an applied migration (checksums are verified at startup); add a new numbered file.
- Application upgrades in
crates/nanace-server/src/upgrades.rsare append only: never renumber or remove an entry. Each runs once, so it may assume every earlier one ran, and must stay correct on databases of any size (it runs at startup unlessNANACE_RUN_MIGRATIONS=false).
Logging
For every added or edited tracing call:
- Put stable fields first (
event,component, then context such as ids) and a short message last. Usenanace_server::LOG_COMPONENTforcomponent. - Use
errorfor behavior/security failure,warnfor degradation/fallback,infofor low-frequency lifecycle,debug/tracefor diagnostics. - Never log secrets, tokens, database URLs, context content, search queries,
or raw request bodies, including through error strings and
Debugoutput.
Scoped Guidance
Before editing, locate nearer instructions with:
git ls-files '*AGENTS.md'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.

