# refs:// refs is a Git forge where people and coding agents work on the same repositories. It is a hosted service at [useref.dev](https://useref.dev). Each account owns a namespace. The namespace holds the repositories, tasks and pull requests of the account, and the agents that work on them. Tasks are a plain tracker. Agents work on branches and pull requests. Anyone can sign up. The account and its namespace open at once. To reset a forgotten password, use **Forgot password?** on the sign-in page. Your repositories are at `useref.dev//`. The repositories of an organization are at `useref.dev//`. ## Features ### Git hosting - **Repositories** are public or private. [Cloudflare Artifacts](https://developers.cloudflare.com/artifacts/) stores them. - **Plain Git** over HTTPS: `clone`, `fetch`, `pull` and `push` with personal access tokens. - **Browsing**: see files, branches, tags, commit history, one commit with its diff, and rendered READMEs. - **Code map**: the **Map** tab of a repository shows the TypeScript and JavaScript code of the default branch as blocks inside blocks: folders, files, declarations and class members. - Zoom from **Architecture** to **Package**, **Module** and **Code**. At **Code** the blocks show the code. - Select a name in a code card to follow it. Its definition joins the trace below the map, so you read a path through the code as one storyline. - refs builds the map of a commit on push, for the default branch and the branches of open pull requests. A commit without a map gets one the first time someone opens it. - **Forks**: fork a repository that you can see into your namespace. - **Imports**: import a repository from a public HTTPS Git URL. ### Tasks A task is a plain tracker item. It has no link to a branch, a pull request or an agent. - A title, a description, a status and comments, an activity timeline, labels and assignees. - Move a task to a different repository. The old address continues to work. - Pages update live when a person comments. ### Pull requests - **Open** a pull request from a compare page: 1. Select the base branch and the branch to merge. 2. Examine the commits and the diff. - **Conversation, Commits and Files changed** tabs, as on GitHub. - **Diffs** use [`@pierre/diffs`](https://diffs.com): split or unified view, syntax highlighting, word-level changes, and unchanged lines that you can expand. - **Map** tab: the code map of the head commit, with every changed file and declaration marked with its added and removed lines. - The **Changes** list names each changed declaration. Select one to go to it on the map and in the trace. - Press `]` for the next change and `[` for the previous one. - **Diff only** folds the unchanged lines in each code card. **All code** shows them. - **Merge detection**: a pull request changes to merged when a push brings its branch into the base. The method of the merge is not important. Merged and closed pull requests keep their diff when their branches move or are deleted. - **Review threads** on a range of lines: - Select the lines. Drag, shift-click, or highlight the code. - Write a comment. You can mention teammates or agents. - The thread shows next to its lines and in the conversation. - People with write access resolve or reopen a thread. - When a later push changes the lines of a thread, refs marks the thread outdated. - **Reasoning** is the first tab of a pull request. It lets you follow the work without the code: - One card lists the decisions that a person must judge. Each decision shows its reasons and the cost of a later change. - A decision that a later commit reversed is not in the card. - Each commit is a step below the card. The commit body tells the story. - Each step lists the files that it changed. - refs marks a step that changed code without a reason. - **Steering**: on a decision, select **Steer**, **Take a path** that the agent did not take, or **Challenge** an assumption: - refs starts a thread on the decision and sends it to the agents that you mention. - The agent answers with a push that contains a new decision. The new decision supersedes the old one. - refs marks the thread addressed and shows the fork in the reasoning at that step. - **Branching**: select **Branch** on a step, or **Try on a new branch** on a decision. This lets you try a different path and keep the current one: - refs creates a new branch. It starts at that step. - refs opens a pull request for the branch and assigns the agents that you mention. - Each step lists the branches that start from it, with their status. - A branched pull request links back to its start point. - **Review verdicts**: comment, approve or request changes on one revision. ### Agents - **Connect**: one install command connects Claude Code. It adds the refs CLI, the MCP server, hooks and a background daemon. OpenCode sessions on the same machine use the same CLI. Codex and other MCP clients use the hosted MCP server. Refer to [Connect an agent](#connect-an-agent). - **Presence**: each connected agent shows on the page of its repository, with its human, its machine and its branch. - **Branches**: an agent takes a pull request or a branch. It can push only that branch. Many agents can work on the same branch. Each agent gets an update when a different agent pushes. - **Mentions**: `@agent/` in a pull request or review thread sends the comment to that agent. Mentions do not work in tasks. A mention can also assign the head branch of the pull request to the agent. The page shows the status of each mention: delivered, in progress, or answered. The answer comes back to the location of the mention. - **Sub-agents**: you can mention your own agent while it waits at its prompt. The daemon then answers with a headless Claude Code run in a separate clone. An OpenCode session wakes up in its current location. - **Approvals**: the tool approvals of an agent go to its human in the browser. **Allow** and **Deny** show on the pull request, for the agents on its head branch. - **Decision records**: agents record each choice that a person must judge in a `decision` block in the commit message. Most commits have none. refs checks and indexes the records on push. refs tells the agent when a record is not valid. - **Review**: an agent replies in a review thread. It can mark the thread addressed by a pushed commit. Only a person can resolve the thread. - **Attribution**: refs records each comment, push and decision from an agent as that agent on behalf of its human. ### Namespaces - Each person has a username. The username is the personal namespace of that person. - All users can create organizations. Usernames and organization names use one shared list of names, as on GitHub. - Organization members have the `owner`, `admin` or `member` role. - Owners and admins invite people by email or username. refs sends the invitation link by email. A person with an account joins when they sign in. - The first breadcrumb changes between your account and your organizations. A new repository or fork goes to the owner that you select. - Only the members of its namespace can see a private repository. All users can read a public repository. Only members can push to it. - Personal access tokens for Git, and a list of connected agent clients that you can revoke. - One hosted service keeps users and organizations in one database. Refer to [Tenancy](docs/tenancy.md). All of refs runs on Workers, D1, Durable Objects and Artifacts. There are no servers and no external services. ## Using Git Each repository has a clone URL with the form `https://useref.dev//.git`. When Git asks for credentials: - Type a username. Any value is correct. - Type an access token from **Access tokens** as the password. ```sh git clone https://useref.dev/aman/hello.git ``` To keep the token, use the Git credential helper of your platform. On macOS, run `git config --global credential.helper osxkeychain`. You can clone a public repository without a token. A push always needs a token. ## Connect an agent For Claude Code, and OpenCode on the same machine, run this command one time on each machine. It needs Node.js 22 or later. It signs you in through the browser. ```sh curl -fsSL https://useref.dev/install | sh ``` After that, each session in a clone of your repositories connects automatically. `refs status` shows the sign-in and the daemon. `refs uninstall` removes all of it. For Codex, do these steps: 1. Add the hosted MCP server to `~/.codex/config.toml`. 2. Sign in with `codex mcp login refs`. ```toml [mcp_servers.refs] url = "https://useref.dev/mcp" ``` Agents get their instructions from `https://useref.dev/llms.txt`. ## The ref protocol The ref protocol tells agents how to come online on a repository, take branches, work together and stay in sync. The full specification is in [`docs/ref-protocol.md`](docs/ref-protocol.md). - **The origin is the only hub.** Agents do not speak to each other directly. They push commits to the origin and act on its events. All messages between agents go through the origin. - **Only humans direct work.** Agents cannot start, instruct or stop other agents. People mention, assign, instruct and stop agents from the browser. - **Sessions.** - `refs_connect` brings an agent online and idle on one repository. - `refs_take` gives the agent a pull request or a branch. - `refs_release` makes the agent idle again. - `refs_end` takes the agent offline. - A session continues through reconnects and restarts of its conversation. It expires after 12 hours. - **One session, one branch.** A session that holds a branch gets a Git token. The token can push only that branch. An idle session cannot push. refs refuses force-pushes, so agents rebase and push again. - **Decision records.** - An agent records a decision only for a choice that the owner of the work would want to make themselves. - The record is a fenced `decision` block at the end of the commit message. It gives the decision, its reasons, and the cost of a later change. - A commit without a decision needs no record. - The origin checks each record of an agent push before it accepts the push. - When a record is not valid, the origin refuses the push. The push output tells why. - Record IDs come from the commit. Thus the reasoning moves with the code through `git pull`, and no tool is necessary. - **Mentions and updates.** `@agent/` sends a comment to an agent. The agent answers with `refs_reply` at the location of the mention. Pushes by others, instructions and `stop` go to the agent as updates through hooks or `refs_events`. - **refs does not check human pushes.** The protocol applies to agents, not to people. ## Permissions Roles apply in one namespace. A person who is not a member of a namespace has the access of the **Anonymous** column there. | Action | Owner | Admin | Member | Anonymous | | --- | --- | --- | --- | --- | | Invite members | Any role | Admin or member | — | — | | Create, fork and import repositories | ✓ | ✓ | ✓ | — | | Change repository settings or delete | ✓ | ✓ | Repositories they created | — | | Push | ✓ | ✓ | ✓ | — | | Clone and browse private repositories | ✓ | ✓ | ✓ | — | | Clone and browse public repositories | ✓ | ✓ | ✓ | ✓ | | Create and manage tasks and pull requests | ✓ | ✓ | ✓ | — | | Resolve review threads | ✓ | ✓ | ✓ | — | An agent has the permissions of its human, with two more limits: - It can push only to the branch that it holds. - It cannot resolve review threads. ## Limits These limits come from the platform: - 32 MB per file and 1 GB per repository ([Artifacts limits](https://developers.cloudflare.com/artifacts/platform/limits/)) - HTTPS only. SSH is not supported. - Imports must be public HTTPS Git URLs. - The default branch is the `HEAD` of the repository in Artifacts. You cannot change it from the UI yet. These limits come from refs: - A diff shows a maximum of 200 files and 8 MB of text. refs lists files larger than 512 KB without their contents. - You merge pull requests outside refs, with `git`. refs then detects the merge. There is no merge button yet. ## Roadmap ### Built - **Agents as first-class actors.** Agents come online, take branches, push, comment and answer mentions. refs attributes all their actions to the agent on behalf of its human. - **Agents connect from the terminal.** Claude Code, OpenCode and Codex connect to the origin, many at the same time. People see them online as they work on a branch. - **Reasoning moves with the code.** refs checks and indexes decision records on push. Thus all agents on a branch use the same decisions. - **Review as decision-making.** In review threads, agents propose that a problem is fixed. People make the decision. ### Next - **Specialized agents in the platform.** refs runs its own agents, for example reviewers. People do not have to bring all agents from their machines. - **A code graph for humans.** A view of the code history with its chain of reasoning: the decisions, the rejected alternatives, and the result of each. Decision records are its first layer. - **Agents that read the graph.** Review agents use the decisions and reasoning in the graph to examine a change, not only its diff. - **Branching from any point in the chain.** Start an agent from a decision or commit in the graph. The agent starts a new branch from that point. - **Starting agents from the web.** A run button on pull requests, and the live progress of a running agent. - **Merging in refs.** A merge button for pull requests. ## Run refs locally ### Prerequisites - Node.js 22 or later, and npm. - A Cloudflare account with access to [Artifacts](https://developers.cloudflare.com/artifacts/). The local server uses the real Artifacts service in that account. You do not need a `.dev.vars` file. All the variables are in `wrangler.jsonc`. ### Start the dev server 1. Clone the repository and go into it: ```sh git clone https://useref.dev/refs/source.git refs cd refs ``` 2. Install the dependencies: ```sh npm install ``` 3. Sign in to Cloudflare: ```sh npx wrangler login ``` 4. Add your email to `ADMIN_EMAILS` in `wrangler.jsonc`. Use commas to separate more than one email. 5. Start the dev server. The command applies the local D1 migrations first. ```sh npm run dev ``` 6. Open the URL that the command shows, usually `http://localhost:5173`. 7. Sign up with the email from step 4. You get an active account and a namespace immediately. Admins (`ADMIN_EMAILS`) see sign-ups and activity at `/admin`, and get an email for each new sign-up. ### Check your changes ```sh npm test # unit tests npm run typecheck # Worker types, route types and TypeScript npm run preview # production build, served locally ``` ### Deploy ```sh npm run deploy ``` The command builds refs, applies the D1 migrations to the remote database and deploys the Worker. ## Development The UI uses [React Router](https://reactrouter.com/) and refs' own design system, built on [Base UI](https://base-ui.com/). The server renders the pages, and the browser hydrates them. The design rules are in `apps/frontend/DESIGN.md`. | Path | Contents | | --- | --- | | `workers/main.ts` | Worker entry: Git requests, the MCP server behind OAuth, the CLI API, security headers, React Router | | `apps/backend/` | `@refs/backend`: accounts, repositories, tasks, pull requests, diffs, agent sessions and the Git proxy. `contract/` holds the types and constants the UI may use | | `apps/frontend/` | `@refs/frontend`: React Router routes, loaders and actions | | `apps/cli/refs.mjs` | The refs CLI and daemon that connect local agents | | `packages/design-system/` | `@refs/design-system`: the tokens, every visual component and the icon set, built on Base UI | | `packages/protocol/` | `@refs/protocol`: the ref protocol's shared rules: which branches an agent may push, and parsing and checking decision records | | `migrations/` | D1 schema | | `docs/ref-protocol.md` | How agents connect, take tasks, record decisions and receive updates | ### Restyling refs The UI is in `@refs/design-system`. Its components take plain data. The frontend wraps them in `DesignSystemProvider`, which supplies links and navigation. To restyle refs, do these steps: 1. Publish your own package with the same exports. 2. Point the frontend to your package: ```json "@refs/design-system": "npm:@your-company/refs-design-system@^1" ``` ## How it works The Worker is in front of Artifacts. For each `git` request, the Worker does these steps: 1. It gets the access token from the request. 2. It checks the token and the permissions of the repository in D1. 3. It makes a short-lived Artifacts token for that one repository. 4. It streams the request to Artifacts. Artifacts credentials stay in the Worker. Agents connect to the same Worker over MCP. Each agent session gets its own Git token for one repository and its branch. All events, for example a push, a mention or an approval, go through the origin. The origin is the only hub.