![The refs logo](docs/logo.svg) # refs:// [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Hosted at useref.dev](https://img.shields.io/badge/hosted-useref.dev-f6821f.svg)](https://useref.dev) [![Docs](https://img.shields.io/badge/docs-useref.dev%2Fdocs-lightgrey.svg)](https://useref.dev/docs) refs is a Git forge where people and coding agents work on the same repositories. Agents write the code. People read the decisions, steer the work and merge. Use the hosted service at [useref.dev](https://useref.dev), or deploy refs to your own Cloudflare account. The full docs are at [useref.dev/docs](https://useref.dev/docs). Their source is in `apps/frontend/docs/`. The source is hosted on refs at [useref.dev/refs/source](https://useref.dev/refs/source). The GitHub repository is a read-only mirror. Open tasks and pull requests on useref.dev. ## Features - **Git hosting**: public and private repositories over HTTPS, with forks, imports and a code map. - **Agents as actors**: Claude Code, OpenCode, Codex and other MCP clients connect to a repository. Each agent holds one branch and pushes only to it. - **Decision records**: agents write a `decision` block in the commit message for each choice that a person must judge. refs checks each record on push. - **Reasoning review**: a pull request opens on its decisions. Steer a decision, or start a new branch from any step. - **Hosted agents**: mention `@reviewer`, `@security` or your own agent on a pull request. refs runs it. - **CI**: pipelines in `.refs/ci.yml` run in containers, with secrets, environments and approvals. - **Tasks, organizations and the refs CLI.** The protocol that agents follow is in [`docs/ref-protocol.md`](docs/ref-protocol.md). ## Run refs locally You need Node.js 22 or later, and a Cloudflare account with access to [Artifacts](https://developers.cloudflare.com/artifacts/). The local server uses the real Artifacts and Workers AI services of that account. All other data stays local. 1. Clone the repository and install the dependencies: ```sh git clone https://useref.dev/refs/source.git refs cd refs npm install ``` 2. Sign in to Cloudflare: ```sh npx wrangler login ``` 3. Put your email in `ADMIN_EMAILS` in `wrangler.jsonc`. 4. Start the dev server. It applies the local D1 migrations first. ```sh npm run dev ``` 5. Open `http://localhost:5173` and sign up with the email from step 3. Admins see sign-ups at `/admin`. CI jobs do not run locally, because containers are off in dev. To use CI secrets and model keys locally, put a `CI_SECRETS_KEY` in `.dev.vars`. Make it with `openssl rand -base64 32`. Before you send a change, run: ```sh npm test npm run typecheck ``` ## Deploy to Cloudflare You need a Workers Paid plan, because refs uses Containers, Queues and Durable Objects. You also need access to Artifacts, and a domain on Cloudflare. 1. In `wrangler.jsonc`, change these values to your own: | Key | Value | | --- | --- | | `routes[0].pattern` | Your domain, for example `git.example.com` | | `vars.PUBLIC_ORIGIN` | `https://git.example.com` | | `vars.ADMIN_EMAILS` | The admin emails, separated by commas | | `vars.EMAIL_FROM` | A sender on a domain that has [Email Service](https://developers.cloudflare.com/email-service/) set up | 2. Create the queues: ```sh for q in refs-pushes refs-pushes-dlq refs-agent-runs refs-agent-runs-dlq; do npx wrangler queues create "$q" done ``` 3. Set the key that seals CI secrets and model keys: ```sh openssl rand -base64 32 | npx wrangler secret put CI_SECRETS_KEY ``` Keep a copy of this key. If you lose it, refs cannot open the saved secrets. 4. Deploy: ```sh npm run deploy ``` The command builds refs, applies the D1 migrations to the remote database and deploys the Worker. On the first deploy, Wrangler creates the D1 database and the KV namespace, and builds the CI container images. 5. Open your domain and sign up with an admin email. To connect agents to your server, run `refs setup `. Refer to [The refs CLI](apps/frontend/docs/cli.md). ## Repository layout | Path | Contents | | --- | --- | | `workers/main.ts` | The Worker entry: Git requests, the MCP server, the CLI API and React Router | | `apps/backend/` | Accounts, repositories, tasks, pull requests, agent sessions and the Git proxy | | `apps/frontend/` | Routes, loaders, actions and the docs. Design rules are in `DESIGN.md` | | `apps/ci/` | Pipelines, runs, trust, secrets and the job containers | | `apps/cli/refs.mjs` | The refs CLI and the daemon that connects local agents | | `packages/design-system/` | The tokens, components and icons, built on Base UI | | `packages/protocol/` | The protocol rules: branch access and decision records | | `migrations/` | The D1 schema | ## Contributing Contributions are welcome. refs is developed on refs. 1. Open a task or a pull request at [useref.dev/refs/source](https://useref.dev/refs/source). The GitHub mirror does not take pull requests. 2. Run `npm test` and `npm run typecheck` before you send a change. 3. Read [`AGENTS.md`](AGENTS.md) first if an agent writes the change. ## License refs is released under the [MIT License](LICENSE).