---
title: "Repo layout"
description: "Folders are agents. Files inherit from root to leaf."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Repo layout

Use one repo per org or team. The repo is the whole backend: every file is human-readable text. Clone and push it like any git remote:

```bash
git clone https://$ORG.cloudraker.run/_git/egr-agents
```

The git remote needs a token with the `git` scope. Send it as `http.extraHeader`, as in the [quickstart](https://docs.cloudraker.com/run/guides/quickstart).

## Example

```text
egr-agents/
  AGENTS.md                 # shared instructions, inherited
  agent.yml                 # shared defaults (model, network, secrets), inherited
  skills/dash0-logs/SKILL.md
  mcp.json
  apps/                     # project apps, never an agent
    claims.json             # native Arc app body
    claims.yml              # stable id, audience, tables and actions
  _schemas/                 # Structured Memory schemas, inherited
    lead.yml
  knowledge/                # Markdown the agents search, never an agent
    sales/pricing.md
  doors/                    # front doors: how people reach the agents, never an agent
    support.yml
  linear-triage/            # agent "linear-triage"
    AGENTS.md
    agent.yml
    _apis/
      linear.openapi.json
    _code/
      label.ts
  csio/                     # agent "csio"
    AGENTS.md
    agent.yml
    skills/file-pdf/SKILL.md
```

## Rules

| Id  | Rule                                                                                                                                                                                |
| --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| R1  | A folder with `AGENTS.md` (or `AGENT.md`) is an agent. `agent.yml` is optional. The folder path is the agent name. A nested agent uses its full path, for example `support/intake`. |
| R2  | Names that start with `_` are reserved: `_apis`, `_code`, `_schemas`, `_run`, `_git`, `_secrets`, `_inbound`, `_slack`. A path segment matches `[a-z0-9][a-z0-9-]{0,62}`.           |
| R3  | An agent inherits every `skills/`, `mcp.json`, `_apis/`, `_code/` and `_schemas/` entry of its ancestors. To avoid one, move the agent to another branch of the tree.               |
| R4  | `AGENTS.md` files concatenate from root to leaf. The leaf comes last.                                                                                                               |
| R5  | `agent.yml` files deep-merge from root to leaf. The leaf wins. A same-named MCP server, API file, script or schema in a child replaces the parent one.                              |
| R6  | No secret values in the repo. Write `${secret:NAME}`. A push that contains a secret fails.                                                                                          |
| R8  | An agent folder cannot contain another agent folder. Lint fails with `nested_agent`.                                                                                                |
| R10 | `knowledge/` at the root holds Markdown for [knowledge](https://docs.cloudraker.com/run/guides/knowledge) search. It never holds an agent. An `agent.yml` in it fails lint with `knowledge_agent_folder`.          |
| R11 | `doors/` at the root holds the [front doors](https://docs.cloudraker.com/run/guides/front-doors), one `doors/{name}.yml` per door. It never holds an agent.                                                        |
| R9  | Only the default branch (`main`) deploys. Other branches get a [preview](https://docs.cloudraker.com/run/guides/protection-and-previews#previews).                                                                 |

R2 also reserves `v2` as the first segment of an agent path: the CloudRaker API uses `/v2` on the org host. Lint refuses `v2/intake` with `reserved_name`. `intake/v2` is correct.

## Inheritance

| Case                                                                     | Result                                                                                         |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |
| Scalar conflict (`timeout`, `model.id`)                                  | The leaf wins.                                                                                 |
| Map conflict (`network`, `secrets`, `model`)                             | Deep-merge by key. Leaf keys win. A leaf cannot remove a parent key.                           |
| List conflict (`model.fallback`, `data.read`, `connectors`, `knowledge`) | The leaf list replaces the parent list. Lists never concatenate.                               |
| Same skill name at two levels                                            | The deeper `skills/{name}/` folder replaces the whole parent folder.                           |
| Same MCP server name in two `mcp.json` files                             | The deeper entry replaces the parent entry. Other entries merge.                               |
| Same `_code` script name at two levels                                   | The deeper script replaces the parent script.                                                  |
| Two scripts with the same stem and different extensions                  | Lint fails with `code_tool_collision`.                                                         |
| A parent file is deleted                                                 | The child resolves without it. The deployment diff shows the removed keys.                     |
| A root `agent.yml` sets a leaf-only key                                  | Lint fails with `root_leaf_key {key}`. See [leaf-only keys](https://docs.cloudraker.com/run/guides/agent-yml#leaf-only-keys). |

The console **Agent detail** screen shows the resolved `agent.yml` and the `AGENTS.md` chain of each agent.

## Tools from the repo

| Source                                 | Tool the model sees                                                                                                                                  |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `skills/{name}/SKILL.md`               | The skill, loaded on demand.                                                                                                                         |
| `mcp.json` (remote servers only)       | `mcp_{server}_{tool}`. The server host joins the network allow list. An optional `tools` list per server keeps only those tools.                     |
| `_apis/*.json` or `*.yaml` (OpenAPI 3) | `call_api` per operation. Over 200 operations, `search_api` instead.                                                                                 |
| `_code/{name}.ts` or `.js`             | `{name}`. One fresh isolate per call.                                                                                                                |
| `events:` in `agent.yml`               | `emit_{name}`.                                                                                                                                       |
| `knowledge:` in `agent.yml`            | `knowledge_search` and `knowledge_read`. Read [Knowledge](https://docs.cloudraker.com/run/guides/knowledge).                                                                        |
| A door with `channels.phone`           | `end_call`, `transfer_call` with `channels.phone.transfers`, `call_phone` with `channels.phone.outbound: true`. Read [Phone numbers](https://docs.cloudraker.com/run/guides/phone). |
| A door with more agents or languages   | `handoff` and `switch_language`. Read [Front doors](https://docs.cloudraker.com/run/guides/front-doors#entry-router-and-handoff).                                                   |

An MCP tool name has at most 64 characters. When `mcp_{server}_{tool}` is longer, Run keeps its first 47 characters and adds `_` and 16 hexadecimal characters of a hash of the server and tool names.

A `_code` script cannot use a built-in tool name or the prefixes `data_`, `file_`, `emit_`, `mcp_` and `knowledge_`. Lint fails with `code_tool_collision`. The names `handoff` and `switch_language` are reserved. An act-as (`workspace_act_as`) or phone tool name gives the same error when that feature is on, else a warning. A phone tool name is an error when a door with `channels.phone` lists the agent.

### OpenAPI files

| Rule      | Detail                                                                                                                               |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Servers   | Only the first `servers[].url` is used. Its host joins the allow list. A relative or templated URL fails lint.                       |
| Tool name | `operationId`. Without one, `{method}_{path}`. Two files with the same id fail lint with `api_tool_collision`.                       |
| Auth      | From `network:` header templates only. `securitySchemes` are ignored. Lint warns when a scheme names a header that `network:` lacks. |
| Size      | 5 MB per file.                                                                                                                       |

### Scripts

A script exports `run(input)`. Its leading comment is the tool description. An `@input` line starts the input JSON Schema, and it is the last part of the comment.

```ts _code/label.ts
// Label a Linear issue.
// @input { type: object, required: [title], properties: { title: { type: string } } }
export function run(input) {
  return { label: input.title.includes('crash') ? 'bug' : 'triage' }
}
```

TypeScript is bundled once per deployment. Outbound calls go through the same network rules as the agent. Limits are in [Limits and pricing](https://docs.cloudraker.com/run/guides/limits-and-pricing).

The agent can also write code during a run:

| Tool           | What it does                                                                                                                                                                                     |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `execute_code` | Runs JavaScript (or TypeScript) once in a fresh isolate. The code can call the agent tools and `_apis` operations as typed functions. Returns `{ result, logs, error }`.                         |
| `save_code`    | Saves a new script to `_code/` on the branch `code/{agent}/{name}` and opens a pull request. A `/` in the agent path becomes `.`. A human merges it. It becomes a tool from the next deployment. |

## Push lint

The gateway lints the tree before it stores the push. A push deploys every agent in the repo or none. One error rejects the whole push. A warning (W) does not block it.

| Check                                        | Rule ids                                                                                                                                                                                  |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| File names                                   | `agent_yml_name` (W), `instructions_duplicate` (W)                                                                                                                                        |
| `agent.yml` parse, schema and leaf-only keys | `agent_yml_parse`, `agent_yml_schema`, `root_leaf_key`, `trigger_invalid`, `event_name`                                                                                                   |
| Names and nesting                            | `invalid_name`, `reserved_name`, `nested_agent`                                                                                                                                           |
| Secrets                                      | `secret_value`, `secret_bare_name`, `secret_undeclared`, `wildcard_header`                                                                                                                |
| OIDC identity                                | `oidc_wildcard`, `oidc_user_audience`, `oidc_header_conflict`, `oidc_scopes_audience`, `user_identity_source`. Read [OIDC identity](https://docs.cloudraker.com/run/guides/oidc-identity#lint-rules).                    |
| OpenAPI, MCP and scripts                     | `openapi_invalid`, `api_tool_collision`, `api_security_header` (W, an `oidc` header counts as supplied), `mcp_json_invalid`, `code_extension`, `code_input_schema`, `code_tool_collision` |
| JSON Schemas                                 | `json_schema_invalid`                                                                                                                                                                     |
| Structured Memory schemas                    | `schema_invalid`, `schema_breaking`, `public_create_schemas`                                                                                                                              |
| Act as a person                              | `act_as_identity_source`                                                                                                                                                                  |
| Agents that work together                    | `agents_target_unknown`, `agents_target_self`, `agents_delegate_cycle` (W), `agents_message_zeroshot` (W), `agents_root_limits` (W)                                                       |
| Knowledge                                    | `knowledge_grant_invalid`, `knowledge_agent_folder`, `knowledge_folder_missing` (W), `knowledge_file_ignored` (W), `knowledge_file_too_large` (W), `knowledge_repo_too_large` (W)         |
| Front doors (`doors/*.yml`)                  | `door_*`, for example `door_unknown_agent` or `door_origin_invalid`. Read the [doors.yml reference](https://docs.cloudraker.com/run/guides/doors-yml#lint-rules).                                                        |
| Phone (`channels.phone` of a door)           | `door_phone_needs_turns`, `phone_number_format`, `phone_text_length`, `phone_voice`, `phone_durations`                                                                                    |
| Old routing files                            | `legacy_routing_file`: a root routing file for Slack or Teams. Move the routing to a door.                                                                                                |
| Imports and size                             | `import_unpinned`, `file_too_large`                                                                                                                                                       |

A failure rejects the push with `ng <ref> <reason>`. The reason has the form `{rule} {path}:{line}: {message}`, for example `ng refs/heads/main root_leaf_key agent.yml:3: ...`.

## Deployments

| Topic         | Rule                                                                                                                                                     |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Pinning       | A run pins the deployment SHA that was live when it started, for all its turns.                                                                          |
| Rollback      | Push a revert, or pick an older version in the console (**Restore version**). It deploys that SHA and leaves the branch head unchanged.                  |
| Removed agent | Its waiting runs finish on the pinned SHA. New starts answer `503 agent_removed`.                                                                        |
| Schedules     | A new deployment replaces the cron schedule of the old one.                                                                                              |
| Front doors   | A push deploys the doors with the agents. A conversation keeps the door version of its start. A removed door makes its bindings answer `door_not_found`. |

Build new [apps](https://docs.cloudraker.com/run/guides/apps) with JSON and the Arc catalog. HTML app bodies are a legacy compatibility format.

Source: https://docs.cloudraker.com/run/guides/repo-layout/index.mdx
