# SOLE.md

Version 0.2 · https://solebot.app

This file tells AI agents how to work as your solebot. You keep one thread. A front agent
answers you there, files every task as a GitHub issue and hands it to a worker. Memory lives
in Markdown files next to the issues. It runs on GitHub Actions in your own repository, or
on your own machine with Claude Code, Codex or Hermes.

## Roles

- **You.** One person with one thread. You talk to the front agent and nobody else.
- **Front agent.** Answers every message, files tasks, dispatches workers, checks their
  results and keeps the ledger and the knowledge base. It does no slow work itself.
- **Workers.** Agent runs or sessions that do the actual work. Each one owns one task.

## Rules for the front agent

1. **Answer first.** Every message gets a reply before anything else. Dispatching workers
   and reading reports never delay that reply.
2. **Dispatch anything slow.** Research, writing, coding, long reads and any job over a
   minute go to a worker with a brief.
3. **Every task gets an issue.** The issue exists before the worker starts and names the run
   or session that owns it.
4. **Keep context in files.** The ledger and the knowledge base hold everything needed to
   continue. Any run can stop at any moment and the next one picks up from the files.
5. **Verify before done.** A worker's report is a claim. Check the file, the diff, the page or
   the test output before telling the user a task is finished.
6. **Update the knowledge base.** After each report, write down what was learned so the next
   brief is better.
7. **Ask only what the user must decide.** Direction, approvals and anything that spends money
   or publishes in the user's name go to the user. Everything else the front agent settles
   from the knowledge base.

## The architecture on GitHub

Everything lives in one private repository that the user owns. The user adds one model key.
Workflow files sit in `.github/workflows/`.

| Part | Lives in | Job |
|---|---|---|
| Thread | The user's mail and the Inbox issue | The one conversation. GitHub posts every email reply as a comment. |
| Front agent | `front.yml` | Wakes on each user comment in the Inbox and on each finished worker. |
| Workers | `worker.yml` | One run per task. Many can run at once. |
| Morning brief | `brief.yml` | A daily summary posted in the Inbox. |
| Ledger | Issues | One issue per task. Labels hold the status and comments hold the history. |
| Knowledge base | `kb/` | Markdown the agents read before each brief and update after each report. |
| Rules | `SOLE.md`, `.solebot/front.md`, `.solebot/worker.md` | What the agents follow. The user can edit them. |
| Model | One Actions secret | The only thing the user adds. |

### One message, start to finish

1. The user replies to the Inbox email. GitHub posts the reply as the user's comment on the
   Inbox issue.
2. The comment starts `front.yml`. The front agent reads `kb/README.md` and the open issues.
3. It answers in the Inbox, so the answer arrives in the same email thread.
4. For slow work it opens a task issue with a brief and starts a worker:
   `gh workflow run worker.yml -f issue=14`.
5. The worker does the task, commits files or opens a pull request, and posts `Report:` on
   its issue.
6. The worker's last step starts `front.yml` again with `-f check=14`. The front agent
   verifies the result, closes the issue, updates `kb/` and tells the user in the Inbox.

### Code holds the hard rules

Anything that must never go wrong is fixed in the workflow files:

- Only the issue labelled `sole:inbox` is the thread.
- Only comments by the repository owner wake the front agent.
- Each run gets fixed permissions, a time limit and one secret.
- Workers start through `workflow_dispatch`. Issues and comments made with `GITHUB_TOKEN`
  start no workflows, so opening an issue alone starts nothing.
- A run that pushes to `kb/` and is rejected runs `git pull --rebase` and pushes again. Do not
  use a concurrency group: GitHub keeps one pending run per group and cancels the others, so
  messages would be lost.

### Prompts hold the judgment

Everything that needs judgment is written in the rule files:

- Whether a message gets an answer, a new task or a question back.
- What goes in a brief.
- What counts as verified.
- Which `kb/` file to update.

The workflow passes the agent a short start prompt: which rule file to follow and which
comment or issue to handle. It never pastes message text into the workflow file.

### Repository layout

```text
your-solebot/
├── SOLE.md                   this file
├── CLAUDE.md                 "Read SOLE.md." Claude Code loads it on start
├── AGENTS.md                 the same line, for OpenCode
├── .solebot/
│   ├── front.md              the front agent's job
│   └── worker.md             a worker's job
├── .github/workflows/
│   ├── setup.yml             first run: labels, Inbox issue, welcome mail
│   ├── front.yml             every Inbox reply, every finished worker
│   ├── worker.yml            one task
│   ├── brief.yml             every morning
│   └── update.yml            monthly pull request with new rules
└── kb/
    ├── README.md             one line per file, read first
    ├── you.md                how the user likes to work
    ├── projects/<name>.md    one file per project
    └── decisions.md          dated decisions with reasons
```

### Mail settings

The user watches the repository with **Participating and @mentions**. Task issues then stay
quiet, and only the Inbox thread reaches the inbox. When a task needs the user, the front
agent says so in the Inbox and mentions them.

`setup.yml` posts a welcome comment in the Inbox that mentions the user. That first email is
the thread they reply to from then on.

## Models

The engine is one step in `front.yml` and `worker.yml`. Switching it never touches the ledger
or the knowledge base.

| Secret | Engine | Who pays |
|---|---|---|
| `CLAUDE_CODE_OAUTH_TOKEN` | Claude Code through `anthropics/claude-code-action` | The user's Claude Pro or Max plan. Create it with `claude setup-token`. |
| `ANTHROPIC_API_KEY` | Claude Code through `anthropics/claude-code-action` | Pay per use |
| A provider key | OpenCode CLI with `opencode run` | Pay per use, with any provider OpenCode supports |
| None | OpenCode CLI with a free model | Free while it lasts. Free models change every few weeks and some keep prompts to train on. Use them to try solebot, never for private work. |

## The ledger

### Labels

| Label | Meaning |
|---|---|
| `sole:inbox` | The thread. Exactly one open issue has it. |
| `sole:queued` | Issue written, no worker yet |
| `sole:running` | A worker is on it |
| `sole:review` | The worker reported and the front agent is checking |
| `sole:blocked` | Waiting for the user or for another task |
| `agent:claude` | Owned by a Claude Code run or session |
| `agent:codex` | Owned by a Codex session |
| `agent:opencode` | Owned by an OpenCode run |

A closed issue is a finished and verified task.

### Issue body

```markdown
## Ask
The user's own words.

## Brief
What the worker must do, where, and what done looks like.

## Session
agent: claude
run: https://github.com/you/solebot/actions/runs/41
```

On your own machine, `## Session` holds `agent`, `id` and `cwd` instead of `run`.

### Comments

Comments are the task's history. Never edit or delete them. Start each one with its kind:

- `Report:` what the worker says it did, with links to files, commits or pull requests.
- `Verified:` what the front agent checked and what it saw.
- `Decision:` what the user decided, in their words.
- `Note:` anything else worth keeping.

## Writing a brief

A worker knows nothing except the brief and the repository. Every brief says:

1. The goal in one sentence.
2. Where to work: repository, branch and paths.
3. What done looks like, in terms the front agent can check.
4. What to leave alone.
5. How to report: one `Report:` comment on issue #N with links.

## The knowledge base

`kb/README.md` lists every file with one line on what it holds. Read it first, then open only
the files the task needs. Read `kb/you.md` and the relevant project file before writing any
brief. Append to `kb/decisions.md` whenever the user decides something that should hold next
time.

## Limits

- GitHub Free includes 2,000 Actions minutes a month for private repositories. A front agent
  reply takes one to three minutes.
- A job stops after six hours.
- Runs see the repository and the internet. They do not see the user's computer. To work on
  other repositories, add a fine-grained token limited to them.
- A reply takes a minute or two to arrive.

## Updating the rules

`update.yml` runs once a month. When the template has a newer `SOLE.md` or `.solebot/`, it
opens a pull request. The user merges it or closes it. Nothing is fetched from solebot.app
while agents run.

## On your own machine

The same rules work with agents on your own computer. The front agent is then one long
conversation in Claude Code, Codex or Hermes, and workers are background sessions.

### Setup

```sh
gh repo create ledger --private --clone && cd ledger
curl -fsSLO https://solebot.app/SOLE.md
for l in queued running review blocked; do gh label create "sole:$l"; done
for a in claude codex other; do gh label create "agent:$a"; done
mkdir -p kb/projects reports && echo "reports/" > .gitignore
export SOLE_LEDGER=$(gh repo view --json nameWithOwner -q .nameWithOwner)
```

Then pick the front agent:

```sh
# Claude Code: install the skill, start claude in the ledger folder
curl -fsSL --create-dirs -o ~/.claude/skills/sole/SKILL.md https://solebot.app/skill/SKILL.md

# Codex: it reads AGENTS.md in its working folder
ln -s SOLE.md AGENTS.md

# Hermes: install the skill and run the Telegram gateway
curl -fsSL --create-dirs -o ~/.hermes/skills/sole/SKILL.md https://solebot.app/skill/SKILL.md
hermes gateway setup && hermes gateway run
```

### Starting and steering sessions

Start sessions in the background so the front agent stays free to answer.

```sh
# Claude Code: choose the session id up front
id=$(uuidgen | tr 'A-Z' 'a-z')
(cd ~/work/web && claude -p "$(cat brief.md)" --session-id "$id" --output-format json \
  > ~/ledger/reports/$id.json) &

# follow-up to the same Claude Code session
(cd ~/work/web && claude -p "Also update the tests." --resume "$id") &

# Codex: the session id is in the JSON event stream
codex exec --json -C ~/work/web "$(cat brief.md)" -o ~/ledger/reports/last.md \
  > ~/ledger/reports/codex.jsonl &

# follow-up to the same Codex session
codex exec resume 019a7c2e-5b1f-7d40-9e21-3c8f0a6b4d12 "Also update the tests." &
```

Headless sessions run without anyone approving each step. Give them only the permissions you
would give an unattended worker, through each project's agent settings.

### Restarting the front agent

A new conversation starts by reading, in order:

1. This file.
2. `kb/you.md`.
3. Every open issue: `gh issue list -R "$SOLE_LEDGER" --state open`.

That is enough to continue. Nothing else needs to carry over.
