Skip to content
[ erkle ]
sign inSign up

How to share coding conventions across repositories

To share a convention across repositories, store it once at the scope it applies to instead of copying it into each repository's CLAUDE.md or AGENTS.md. Copies drift: one repo gets the fix, four don't, and agents follow whichever copy they read.

In Erkle, every memory belongs to one scope: the team, a project, or a repository. Projects group repositories, and a repository can belong to several projects. A search from a repository reads that repository, every project it belongs to, and the team, and nothing else.

// facts checked

team: acmeproject: Commerceconventionwritten onceproject: Mobilewebapipaymentsui-kitioseach repo's search finds itin Commerce and Mobile
# A rule written once for the Commerce project reaches every repository in it, including a shared library that also belongs to Mobile.

## facts

The three scopes

Team
Read by everyone on the team. Reviewed by owners and admins. For rules every repository follows.
Project
Read by the project's members. Reviewed by its maintainers. For rules shared by a group of repositories.
Repository
Read by members of the projects that link it. Reviewed by their maintainers. For one codebase's own rules.
A search reads
The repository it runs from, every project that repository belongs to, and the team
Same repository
SSH and HTTPS remotes, a trailing .git, and letter case all resolve to one repository

## steps

Lay out shared conventions

  1. Put each rule at the widest scope where it's true

    Logging and secret-handling rules usually belong to the team. API versioning or event naming that a group of services shares belongs to their project. A build quirk in one codebase belongs to that repository. If you're unsure, start narrow: moving a rule up later is one edit.

  2. Group repositories into projects

    Make a project for each group of repositories that shares rules, such as a product area or a platform. Link a shared library to every project that depends on it, so it reads all of their conventions and they read its interface contracts.

  3. Let agents identify the repository

    Agents pass the output of git remote get-url origin with each search and write. Erkle matches it to the registered repository, so it doesn't matter whether a teammate cloned over SSH or HTTPS.

    git remote get-url origin
  4. In a monorepo, name the package in the memory

    A monorepo has one remote, so it's one repository scope. Put the package or path in the title and tags of a package-specific memory (for example, "apps/web: use the shared fetch wrapper"), so search matches it when an agent works there.

  5. Import the rules you already have

    Ask a connected agent to import the conventions from each repository's CLAUDE.md, AGENTS.md, and docs. Each call takes up to 100 memories for one scope and reports a result for each. Rules that turn out to be the same in every repository can then be merged into one team or project memory.

# One convention, written once for the project, found from any of its repositories
● erkle.memory_create
  type   convention
  title  Version public APIs in the path: /v1/, /v2/
  scope  project:commerce
⎿ proposed · awaiting review by a Commerce maintainer

## faq

cross-repo-conventions --help

? How do I share one CLAUDE.md or AGENTS.md across many repositories?

Keep each repository's file for what's specific to it, such as build and test commands, and move the shared rules into Erkle at team or project scope. A line in each file tells agents to search Erkle before a task, so the shared rules arrive without being copied. Erkle vs. AGENTS.md →

? Does Erkle work with monorepos?

Yes. A monorepo is one repository scope, and every agent working in it reads its memories along with its projects' and the team's. Name the package or path in a package-specific memory's title and tags so search finds it for work in that package.

? What if a repository is an exception to a team rule?

Write the exception as a memory in that repository and say which team rule it replaces. Search returns relevant memories from every scope the repository reads, each labeled with its scope, so the agent sees both the rule and the exception.

? Can a repository belong to more than one project?

Yes. A shared library or a platform service can be linked to every project that uses it. A search from that repository reads all of those projects' memories, and members of any of them can read the repository's own memories.

One memory. Every agent on the team.