Repository Instructions

ElasticClaw detects repository-owned agent instruction files after cloning workspace repositories and makes them visible to the agent.

How it works

Workspaces can define general agent guidance in their own AGENTS.md. Repositories can also own instructions in their root directory. During bootstrap, ElasticClaw scans cloned workspace repositories for supported instruction files and writes a generated index named REPO_INSTRUCTIONS.md.

The generated index references repository-owned files instead of copying their contents. This keeps repository policy in the repository and avoids overwriting files maintained by the project.

Supported files

ElasticClaw currently detects these files at the root of each cloned repository:

AGENTS.md - General agent instructions.

CLAUDE.md - Claude-oriented project instructions.

GEMINI.md - Gemini-oriented project instructions.

text
workspace/
|-- AGENTS.md
|-- REPO_INSTRUCTIONS.md
\-- my-app/
    |-- AGENTS.md
    |-- CLAUDE.md
    \-- package.json

Generated index

When one or more supported files are found, ElasticClaw creates REPO_INSTRUCTIONS.md in the workspace root. The file lists each repository and the instruction files that apply inside it.

markdown
# Repository Instructions

ElasticClaw detected repository-owned agent instruction files. Read the relevant files before making changes in that repository.

## my-app

- `my-app/AGENTS.md`
- `my-app/CLAUDE.md`
If no supported instruction files are found, ElasticClaw removes any stale generated REPO_INSTRUCTIONS.md from the workspace.

Workspace AGENTS.md reference

ElasticClaw also ensures the workspace-level AGENTS.md points agents to the generated index. If the workspace already has an AGENTS.md, ElasticClaw appends the repository instruction section once. It does not overwrite existing workspace instructions.

markdown
## Repository Instructions

If `REPO_INSTRUCTIONS.md` exists, read it before working inside any cloned repository. It lists repository-owned instruction files such as `AGENTS.md`, `CLAUDE.md`, and `GEMINI.md`.

Repository setup

Put repository-specific rules in the repository root when they should travel with that codebase. Use workspace instructions for shared runtime policy, tool usage, and organization-wide preferences.

markdown
# my-app/AGENTS.md

Before changing code in this repository:

- Run npm test before opening a PR.
- Keep database migrations backward compatible.
- Do not edit generated files under src/generated/.
- Prefer existing service helpers over new HTTP clients.
yaml
# .elasticclaw/workspaces/product/elasticclaw-config.yaml
schema_version: v1
name: product

repositories:
  - repo: acme/my-app
    permissions: write
  - repo: acme/shared-lib
    permissions: read

provider: daytona

Bootstrap timing

For managed providers, ElasticClaw waits until bootstrap has cloned repositories, configured credentials, discovered repository instructions, and marked the environment ready before waking the agent. This avoids the agent starting work before instruction files are available.

daytona, replicated, and exedev wait for bootstrap readiness before initial wake-up.

Other providers preserve existing wake behavior and can start as soon as the agent connection is ready.

Failure behavior

Repository instruction discovery is best-effort. If discovery fails after repositories are cloned, ElasticClaw logs a warning and lets the agent continue. The repository files are still present; only the generated index may be missing.

Keep root instruction files small and direct. Use them to point to longer project docs when needed, but put the critical agent rules in the root file.