agentleFS
kalaverinkalaverin/skills/entity-protocol/SKILL.md

entity-protocol

Skill1 starsChanged 3 days agoBSD-3-ClauseView on GitHub

MANDATORY core standard for the repo (entity) concept and the SINGLE namespace registry for all Serena memory scopes: repo definition, naming, the prerequisite gate, one-repo-per-run, identity/provenance/freshness rules, and the canonical repos/ memory layout summary. Type detection and the audit pipeline live in repo-audit; general memory mechanics live in serena-protocol.

The file

Show its rules and text

We split this skill into the rules it gives an agent

20 rules. About 0 are common, 12 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Before creating any repo-scoped memory (bugs/<repo>/..., decisions/<repo>/..., notes/<repo>/..., style/<repo>/..., plans/<repo>/..., …

    line 38
  2. Distinctive:

    STOP all repo-scoped memory writes.

    line 42
  3. Very specific:

    Ask the user to create the first repo card using the repo-audit skill.

    line 43
  4. Distinctive:

    Do NOT guess, infer, or default to a name based on directory names.

    line 44
  5. Distinctive:

    STOP all memory writes for that repo.

    line 48
  6. Very specific:

    Ask the user to create the repo card via repo-audit or confirm the correct repo name from existing cards.

    line 49
  7. Distinctive:

    Do NOT create the repo card implicitly and do NOT guess.

    line 50
  8. Distinctive:

    Every analysis run accepts exactly ONE repo.

    line 58
  9. Very specific:

    All Serena memory namespaces/scopes are defined HERE — the single normative source for the entire skills repository.

    line 65
  10. Distinctive:

    Granularity (HARD): keep each finding memory short and focused on ONE topic.

    line 117
  11. Distinctive:

    Use the meta-entity for knowledge that concerns the project as a whole rather than any single repo.

    line 144
  12. Very specific:

    No name collision: project/<topic> (cross-cutting scope of project-wide knowledge) and <domain>/project/<topic> (findings about the …

    line 145
  13. Distinctive:

    Do not read every reference file.

    line 165
  14. Distinctive:

    Do NOT write repo-scoped memory before the prerequisite gate passes (§3).

    line 185
  15. Distinctive:

    Do NOT guess repo names from directory names.

    line 186
  16. Very specific:

    Do NOT source repo identity metadata from the .serena host project — always from the repo's own git.

    line 187
  17. Very specific:

    Do NOT re-read code covered by a fresh card (commit == HEAD).

    line 188
  18. Distinctive:

    Do NOT define, restate, or own a memory scope anywhere outside §5 — the registry is single.

    line 189
  19. Very specific:

    Do NOT use the reserved scope name cards/.

    line 190
  20. Distinctive:

    Violation protocol: if you write repo-scoped memory in violation of the gate, naming, provenance, or freshness rules, halt immediately, …

    line 192

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SKILL: Entity Protocol (Repo Concept & Namespace Standard)

This skill is the single normative source for the repo concept and for all Serena memory namespaces/scopes. Terminology migration: entity and repo are full synonyms; repo (рус. «репо») is the new canonical term.

Skill boundary. This skill owns: the repo CONCEPT (definition, naming, gates, identity, freshness), the SINGLE namespace registry (every scope, its semantics, and its routing rules), repo-scoped findings semantics and evidence rules, the deprecation registry, card production rules, and the canonical repos/ memory layout. It does NOT own general memory mechanics (metadata headers, mutation protocol, persistence) — those live in serena-protocol. It does NOT own type detection, per-type interface extraction rules, or the audit pipeline that PRODUCES the artifacts — those live in repo-audit.

1. What a Repo (Entity) Is

[ref: #entity-definition]

  • A repo (legacy: entity) is a service, library, repository, infrastructure/GitOps component, or any other project component that owns a canonical card at repos/<repo>/overview in Serena memory.
  • The card is the usability token: a repo is usable for repo-scoped memory only after its card exists. project/repos (legacy: project/entities) is a curated name registry only — it groups recognized names but does NOT authorize memory writes or card creation.
  • The card at repos/<repo>/overview holds the technical overview only. Business-domain knowledge lives at repos/<repo>/business (+ split files); dependency knowledge at repos/<repo>/dependencies; findings live under the findings scopes — semantics in §5. No findings inside the card.
  • Examples of valid registries: monorepo (client_api, billing_wf, payment_lib, production); game project (engine, renderer, physics, audio, ui); dotfiles (dotbot, dotbot_git, shell, text, scripts).

2. Naming

[ref: #entity-naming]

  • Canonical repo name: snake_case with underscores, NO hyphens. Directory dashes convert to underscores (my-service → my_service).
  • The agent renames non-compliant memory paths immediately per serena-protocol [ref: #serena-naming] before any analysis.

3. The Prerequisite Gate (HARD RULE)

[ref: #entity-prerequisite]

Before creating any repo-scoped memory (bugs/<repo>/..., decisions/<repo>/..., notes/<repo>/..., style/<repo>/..., plans/<repo>/..., proposals/<repo>/..., proposal/<repo>/..., reports/<repo>/..., todo/<repo>/..., deprecations/<repo>/..., feature/<repo>/..., or anything under repos/<repo>/...), the agent MUST verify that the target repo already has a card at repos/<repo>/overview.

If no repo cards exist yet (repos/ scope is empty):

  1. STOP all repo-scoped memory writes.
  2. Ask the user to create the first repo card using the repo-audit skill.
  3. Do NOT guess, infer, or default to a name based on directory names.

If the target <repo> does not have a card:

  1. STOP all memory writes for that repo.
  2. Ask the user to create the repo card via repo-audit or confirm the correct repo name from existing cards.
  3. Do NOT create the repo card implicitly and do NOT guess.

Exemption (FULL repo-audit runs): artifacts created by a sanctioned FULL repo-audit run — including the repos/<repo>/glossary seed and any preanalysis_reports — MAY be written before the card exists, because the run's own synthesis produces the card. The exemption covers only the run's own intermediate artifacts; any other repo-scoped write still requires the card.

4. One Repo Per Run

[ref: #entity-one-repo-per-run]

  • Every analysis run accepts exactly ONE repo. If the request mentions multiple repos, STOP and ask the user to pick one. Do not batch repos.
  • Exception: the project-level dependency index (project/dependencies) is inherently multi-repo and is generated only on explicit user request after every repo has a fresh repos/<repo>/dependencies.

5. The Namespace Registry (SINGLE SOURCE)

[ref: #entity-namespace-registry]

All Serena memory namespaces/scopes are defined HERE — the single normative source for the entire skills repository. No other file may define, restate, or own a scope.

Scope creation (HARD, no deviations, no agent skips): any new scope is born ONLY with explicit user approval. The agent that believes a new scope is needed MUST STOP, present the case and the options to the user, and wait for an explicit decision. Two approved forms exist: (1) registered scopes — durable, cross-project; this registry itself is amended (the user approves the edit); (2) session scopes — workspace-local, approved in conversation and recorded in agent/rules (a compressed note: scope exists, what it holds, when to read it at minimum); session scopes are NEVER added to this registry. Writing to a scope that is neither registered nor user-approved is a HARD FAIL.

ScopeStructurePurpose
agent/agent/<topic>Agent behavior rules, deprecations, contradictions, known issues, user preferences.
project/project/<topic>Project-wide information: glossary, dependency graph, tech stack, repo registry.
meta/meta/<topic>Meta-information about conventions (e.g., how to name memories, skill structure).
prompts/prompts/<topic>Orchestration prompts for root/subagent workflows.
templates/templates/<topic>Repo-card templates.
repos/repos/<repo>/...Canonical repo cards (overview) and repo analysis (business, dependencies, glossary, split-model subdirs). No findings.
standard/standard/<family>/<family>_<id>.mdFetch-once archive of authoritative standards (full raw bodies). Families: rfc, std, bcp, pep, aip, owasp, w3c, whatwg, zmpc, cwe.
audit/audit/[<entity>/]<sast_suffix>/SAST audit artifact trees (manifest, plan, architecture, module reports, validation, final report). Owner: security-audit.
review/review/[<entity>/]{feature,project}_<datetime>.mdMachine-readable code-review reports. Owner: code-review.
feature/feature/<repo>/<feature>/...Feature workspaces: free-form per-feature trees for describing, planning, discussing, and tracking features (description, discussion log, plan, status links). The meta-entity project covers cross-project features. No owner skill; internal structure is fully free.
solutions/solutions/<repo>/<subject>/Discuss-first approval journals: the solution.md + decisions.md finale plus stages/ per-approval-event cards (begin.md, NN_<topic>.md, fractional NN_M_<topic>.md). Owner: discuss-first (the full contract lives in discuss-first/SKILL.md §13).
archive/archive/<feature>/Archived completed-feature records: flat feature-keyed trees (fixed core summary.md + decisions.md + future.md, additive free tree, scraps.md) carrying archived_from_commit for git-based recovery of the deleted originals. One feature key covers all repos the feature spanned. Owner: feature-archival.
Findings scopes<domain>/<repo>/<topic>Repo-scoped findings (bugs, decisions, notes, style, todo, plans, proposals, reports, deprecations) — semantics in the subsection below.

Strict routing rules:

  • agent/rules: Contains the ## Contradictions log.
  • agent/deprecations: Project-wide deprecation registry; per-repo deprecations live in deprecations/<repo>/ — semantics in [ref: #entity-deprecations].
  • project/repos: Canonical registry of repos recognized in this workspace. Row format (routing-only — four columns, no domain facts; the card stays canonical, the registry is a derived index written by repo-audit): | Repo | Type | Lang | Skills |, where Lang = the repo's primary language/runtime (single value). Read at bootstrap memory priming; consumed by the repo-routing rule in the frontmatter-protocol include extension.
  • project/<topic>: Project-wide knowledge (glossary, dependency graph, tech stack).
  • repos/<repo>/overview: Canonical repo card ONLY. No findings here. Layout contract: [ref: #entity-memory-layout].
  • repos/<repo>/...: Repo analysis output (business, entities/, processes/, rules/, integrations/, risks/, glossary, dependencies) — produced by the repo-audit skill. Layout contract: [ref: #entity-memory-layout].
  • guide/<topic>: Manuals, onboarding docs, and reference literature for users.
  • artifacts/<topic>: Artifacts produced during agent work (diagrams, exported data, intermediate dumps).
  • playbook/<topic>: Agent-facing instructions, scripts, and repeatable procedures.
  • standard/<family>/<family>_<id>.md: Fetch-once archive of authoritative standards — written ONLY by the archival pipeline owned by the read-for-comments skill (families and fetch URLs live there). Project-wide (repo: generic), exempt from the prerequisite gate. Raw bodies stay untouched below the synthetic H1.

Findings scopes: semantics and when to record

Findings are repo-scoped memories about a repo (or the meta-entity). They MUST NEVER be placed inside the repos/<repo>/overview card.

Scope semantics:

  • bugs/<repo>/<topic>: broken behavior, Sentry exceptions, contract mismatches.
  • decisions/<repo>/<topic>: architectural choices (e.g., "intentionally stateless"); follows the ADR discipline (Architecture Decision Records, Michael Nygard 2011 — context, decision, consequences; lifecycle statuses proposed/accepted/deprecated/superseded map to optional tags).
  • notes/<repo>/<topic>: observations, caveats, hardcoded constants, surprising patterns, missing docs.
  • style/<repo>/<topic>: project/repo-specific style conventions, technical debt, deprecated library usage, naming inconsistencies.
  • todo/<repo>/<topic>: TODOs from code/docs for humans and agents.
  • plans/<repo>/<topic>: complex multi-step plans or investigations.
  • proposals/<repo>/<topic>: proposed code changes, alternative solutions, session results; proposal/<topic> or proposal/<repo>/<topic> for not-yet-accepted agent proposals.
  • reports/<repo>/<topic>: agent reports (reviews, incident investigations, feature research).
  • deprecations/<repo>/<topic>: deprecated repo-local names, aliases, and their canonical replacements.
  • feature/<repo>/<feature>/...: per-feature workspace trees — description, planning, discussion log, status tracking. Fully free internal structure, no owner skill. Cross-project features use the meta-entity: feature/project/<feature>/....
  • solutions/<repo>/<subject>/: Discuss-first Solutions Journal trees (stage journal + finale). Cards are written by direct disk write under the discuss-first §13 contract — the only scope with a waived MCP write path (waiver: mem:agent/allowed_violations); the prerequisite gate applies to concrete <repo> as usual.
  • archive/<feature>/: archived completed-feature records, written only by the on-demand feature-archival pipeline on the user's explicit closing command. Flat and feature-keyed (a feature spans repos) — no <repo> component, so the prerequisite gate is inapplicable here.

Granularity (HARD): keep each finding memory short and focused on ONE topic. A report item that mixes two topics becomes two memories. Never append unrelated findings to an existing memory.

When to record:

TriggerTarget namespace
Confirmed bugbugs/<repo>/<topic>
Architectural decision or trade-offdecisions/<repo>/<topic>
Strange pattern, caveat, observationnotes/<repo>/<topic>
Coding style convention or technical debtstyle/<repo>/<topic>
Proposed change/refactoring/alternative solutionproposals/<repo>/<topic>
Short actionable item from code/docstodo/<repo>/<topic>
Complex multi-step plan or investigationplans/<repo>/<topic>
Agent reportreports/<repo>/<topic>
Deprecated name/alias of the repodeprecations/<repo>/<topic>

The meta-entity project

The name project is a RESERVED meta-entity representing the whole project. The repo-scoped grammar is uniform:

<domain>/<repo>/<topic>,  where <repo> is a concrete repo OR the meta-entity `project`

Rules:

  • The meta-entity exists by definition — the project always exists. It is EXEMPT from the prerequisite gate ([ref: #entity-prerequisite]): no card is required to write bugs/project/..., decisions/project/..., notes/project/..., plans/project/..., reports/project/..., etc.
  • Use the meta-entity for knowledge that concerns the project as a whole rather than any single repo.
  • No name collision: project/<topic> (cross-cutting scope of project-wide knowledge) and <domain>/project/<topic> (findings about the meta-entity) are distinct, valid roles of the same name.

Legacy scope mapping and the physical migration procedure: [ref: #entity-migration-legacy] in references/memory_layout.md.

6. Identity, Provenance, and Freshness

[ref: #entity-freshness]

  • A repo's identity includes its own git branch, latest short commit hash (7 chars), and commit datetime (UTC ISO 8601). These are ALWAYS sourced from the repo's own git repository, NEVER from the .serena host project.
  • The repo field (domain axis, legal values <repo-name> / generic, lazy legacy normalization, and the git-anchor chain) is owned by [ref: #entity-repo-field] in references/repo_memory.md. Tracking field mechanics (field set, git commands, timestamps, refresh-on-mutation) are owned by the frontmatter-protocol tracking extension.
  • Freshness rule: before trusting a repo-specific memory (where repo is not generic), compare its commit/committed_at against the repo's current HEAD. On mismatch the memory is potentially stale: run git diff <memory-commit>..HEAD, reconcile claims against the diff, update or append a divergence note; if reconciliation is impossible, inform the user and ask how to proceed. The check does NOT apply to memories with repo: generic (including legacy serena/project values pending lazy normalization).
  • Freshness gate (analysis-time, HARD): before generating downstream artifacts (dependency cards), every input memory's frontmatter commit must match the repo HEAD and all input memories must be mutually consistent. Any stale/missing/inconsistent input → STOP, report the exact mismatch, and offer the REFRESH mode of repo-audit (or reconciliation via serena-audit).
  • Exploration by mode: a FULL audit ALWAYS explores the codebase — existing memory is context, never a substitute. In PARTIAL mode, fresh inputs (commit == HEAD) are consumed from memory without re-reading code. In REFRESH mode, work is strictly diff-driven: git diff <card-commit>..HEAD per card, for ANY diff size — the codebase is never re-read wholesale.

7. Canonical Memory Layout

The canonical repos/ memory layout contract and the legacy migration procedure live in references/memory_layout.md ([ref: #entity-memory-layout], [ref: #entity-migration-legacy]).

8. Lazy-Load Routing Index

Do not read every reference file. Extract only the sections needed, per the frontmatter-protocol lazy-load mechanics.

Trigger / situationFileAnchor
Producing or updating a repo card: root/subagent workflow, constraints, tree fallbackreferences/card_production.md[ref: #entity-card-workflow]
Card quality gate before savingreferences/card_production.md[ref: #entity-card-quality]
Card content exclusions (what never goes into a card)references/card_production.md[ref: #entity-card-exclusions]
Card hard fails and mistake avoidancereferences/card_production.md[ref: #entity-card-hard-fails]
Card frontmatter header examplereferences/card_production.md[ref: #entity-card-header-example]
The repos/ layout contract, all paths and decisionsreferences/memory_layout.md[ref: #entity-memory-layout]
Migrating legacy entities/, logic/, project/entities memoriesreferences/memory_layout.md[ref: #entity-migration-legacy]
The repo field: domain axis, legal values, git-anchor chainreferences/repo_memory.md[ref: #entity-repo-field]
Findings severity/location/hash evidence formatreferences/repo_memory.md[ref: #entity-findings-traceability]
Deprecated repo names and aliases registryreferences/repo_memory.md[ref: #entity-deprecations]
Type detection (presets + custom:<slug>) and per-facet interface exhaustivenessrepo-audit/references/analysis/type_detection.md[ref: #repo-type-detection], [ref: #repo-interface-exhaustiveness]

Extract a section per the canonical loader mechanics in frontmatter-protocol [ref: #lazy-load-routing] (bounded extraction — never a blind rg -A N window; the exact command lives there, not here).

Do Not

  • Do NOT write repo-scoped memory before the prerequisite gate passes (§3).
  • Do NOT guess repo names from directory names; ask the user.
  • Do NOT source repo identity metadata from the .serena host project — always from the repo's own git.
  • Do NOT re-read code covered by a fresh card (commit == HEAD); work diff-driven when stale.
  • Do NOT define, restate, or own a memory scope anywhere outside §5 — the registry is single.
  • Do NOT use the reserved scope name cards/.

Violation protocol: if you write repo-scoped memory in violation of the gate, naming, provenance, or freshness rules, halt immediately, discard the offending operation, reload the violated section, and redo the operation correctly.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.