Docs: guides for using the factory on your repository and on itself #25

Merged
dario merged 1 commit from dario/sandbox-guides into main 2026-11-19 15:05:17 +01:00 AGit
Owner

Summary

Two step-by-step guides, so that someone can get from an empty machine to factory runs without piecing it together from the README, the deploy guide and sandbox/README.md.

  • docs/using-the-factory.md: using the factory on your own repository.
    1. Prerequisites.
    2. Forge account choice (bot or personal), token and branch protection.
    3. Preparing the repository (AGENTS.md, tests that run in the sandbox, CI, issues written as tasks).
    4. A sandbox defined as a host-side project profile (~/.config/factory/projects/<name>/), copied from sandbox/ and kept out of the repository.
    5. Adapting the environment file, the kit (network rules, credential, setup hook), the Dockerfile and factory.json.
    6. Storing secrets, building the factory into the kit, creating and checking the sandbox, and a first interactive run.
    7. Daily use, updates, troubleshooting and a security checklist.
  • docs/developing-the-factory.md: entering the factory-dev sandbox and the loop for improving the factory with the factory. This covers issue, implement-issue, human review and merge, then loading the merged code back into the sandbox (the skills and prompts are built into the binary, so a merge changes nothing in the sandbox until the binary is rebuilt). It also covers improve-factory and working by hand in the sandbox.
  • justfile: just sandbox-kit takes an optional kit directory, so it can build the factory into a project's own kit. The default (sandbox/factory-dev) is unchanged.
  • Links to both guides from README.md, AGENTS.md, docs/deploy-microvm.md and sandbox/README.md.

Evidence

This PR changes AGENTS.md by one sentence: the pointer to the two new guides. It changes no rule. The reason: the setup was spread over README.md, docs/deploy-microvm.md and sandbox/README.md. None of those described how to enter the factory-dev sandbox for development, how merged changes reach it, or how to make a sandbox for another repository. The guides were requested directly by the maintainer; there are no failed runs or reviews behind this change.

Tests

  • just check passes. Only docs and the justfile changed.
  • just sandbox-kit <dir> built factory-amd64 and factory-arm64 into a scratch directory (static Linux ELF binaries for x86-64 and aarch64).
  • A script checked every relative link and anchor in the changed docs. All of them resolve.

Needs human attention

Neither guide has been followed end to end in a real sandbox. Please check these points in particular:

  • Kit renaming: using-the-factory.md step 4 renames the kit's directory, .yaml and .dockerfile together (factory-dev → app). I assumed sbx matches them by name, as the template's layout suggests. That assumption is not verified.
  • Other toolchains: only the template's toolchain (Go, just, jq, OpenCode) has been built. For other languages the guide gives the Dockerfile rules, not a tested recipe.
  • GitHub: the kit's credential@1 block (Authorization: token %s) is for Forgejo, Gitea and Codeberg. For GitHub the guide refers to the manual setup instead, per ADR 0013.
  • Manual clone: the clone in the sandbox uses git -c http.extraHeader="Authorization: token $FACTORY_FORGE_TOKEN", relying on the proxy replacing the placeholder, as it does for the factory's own git calls.
  • Existing broken anchor: not touched here. The README links to #tests, but the heading is "Tests and static analysis".

🤖 Generated with Claude Code

## Summary Two step-by-step guides, so that someone can get from an empty machine to factory runs without piecing it together from the README, the deploy guide and `sandbox/README.md`. - **`docs/using-the-factory.md`**: using the factory on your own repository. 1. Prerequisites. 2. Forge account choice (bot or personal), token and branch protection. 3. Preparing the repository (`AGENTS.md`, tests that run in the sandbox, CI, issues written as tasks). 4. A sandbox defined as a **host-side project profile** (`~/.config/factory/projects/<name>/`), copied from `sandbox/` and kept out of the repository. 5. Adapting the environment file, the kit (network rules, credential, setup hook), the Dockerfile and `factory.json`. 6. Storing secrets, building the factory into the kit, creating and checking the sandbox, and a first interactive run. 7. Daily use, updates, troubleshooting and a security checklist. - **`docs/developing-the-factory.md`**: entering the `factory-dev` sandbox and the loop for improving the factory with the factory. This covers issue, `implement-issue`, human review and merge, then **loading the merged code back into the sandbox** (the skills and prompts are built into the binary, so a merge changes nothing in the sandbox until the binary is rebuilt). It also covers `improve-factory` and working by hand in the sandbox. - **`justfile`:** `just sandbox-kit` takes an optional kit directory, so it can build the factory into a project's own kit. The default (`sandbox/factory-dev`) is unchanged. - **Links** to both guides from `README.md`, `AGENTS.md`, `docs/deploy-microvm.md` and `sandbox/README.md`. ## Evidence This PR changes `AGENTS.md` by one sentence: the pointer to the two new guides. It changes no rule. The reason: the setup was spread over `README.md`, `docs/deploy-microvm.md` and `sandbox/README.md`. None of those described how to enter the `factory-dev` sandbox for development, how merged changes reach it, or how to make a sandbox for another repository. The guides were requested directly by the maintainer; there are no failed runs or reviews behind this change. ## Tests - `just check` passes. Only docs and the `justfile` changed. - `just sandbox-kit <dir>` built `factory-amd64` and `factory-arm64` into a scratch directory (static Linux ELF binaries for x86-64 and aarch64). - A script checked every relative link and anchor in the changed docs. All of them resolve. ## Needs human attention Neither guide has been followed end to end in a real sandbox. Please check these points in particular: - **Kit renaming:** `using-the-factory.md` step 4 renames the kit's directory, `.yaml` and `.dockerfile` together (`factory-dev` → `app`). I assumed `sbx` matches them by name, as the template's layout suggests. That assumption is not verified. - **Other toolchains:** only the template's toolchain (Go, just, jq, OpenCode) has been built. For other languages the guide gives the Dockerfile rules, not a tested recipe. - **GitHub:** the kit's `credential@1` block (`Authorization: token %s`) is for Forgejo, Gitea and Codeberg. For GitHub the guide refers to the manual setup instead, per ADR 0013. - **Manual clone:** the clone in the sandbox uses `git -c http.extraHeader="Authorization: token $FACTORY_FORGE_TOKEN"`, relying on the proxy replacing the placeholder, as it does for the factory's own git calls. - **Existing broken anchor:** not touched here. The README links to `#tests`, but the heading is "Tests and static analysis". 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- docs/using-the-factory.md: step by step from an empty machine to the
  factory opening pull requests on your own repository: forge account,
  token and branch protection, preparing the repository, a sandbox
  defined as a host-side project profile copied from sandbox/, adapting
  the kit and factory.json, bootstrapping and checking the sandbox,
  daily use, updates, troubleshooting and a security checklist.
- docs/developing-the-factory.md: entering the factory-dev sandbox and
  the loop for improving the factory with the factory, including how
  merged changes reach the sandbox (rebuilt binary).
- just sandbox-kit takes an optional kit directory, so it can build the
  factory into a project's own kit; the default is unchanged.
- Links from README.md, AGENTS.md, docs/deploy-microvm.md and
  sandbox/README.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ -0,0 +8,4 @@
You need `sbx` 0.45 or later, Go and `just`, and a checkout of this repository.
1. **Store the forge token** in your OS keychain. Use a token limited to the repositories the factory works on ([docs/tokens.md](tokens.md)):
Author
Owner

why in the OS keychain? It should not matter where we store it, only that we set it as a sandbox secret

why in the OS keychain? It should not matter where we store it, only that we set it as a sandbox secret
@ -0,0 +21,4 @@
sbx env run sandbox/
```
`sbx` shows a plan: the kit's network rules and its request to use the `factory-forge` credential on `git.darioveltri.de`. Approve it. You land in a bash shell inside the sandbox.
4. **Sign in to Claude**, if this machine hasn't yet: run `claude`, then `/login`, then exit Claude Code. The login stays on the host.
Author
Owner

this is a too specific instruction. I might not want to use claude, I could also work on it using opencode+a local model.

this is a too specific instruction. I might not want to use claude, I could also work on it using opencode+a local model.
@ -0,0 +46,4 @@
1. **Describe the change as a forge issue** in `dario/factory`, in the forge's web UI. Say what is wrong, what done looks like and how to verify it.
2. **Implement it in the sandbox:**
```sh
factory run implement-issue -repo dario/factory -item 14 -interactive
Author
Owner

use a placeholder for the issue number

use a placeholder for the issue number
@ -0,0 +50,4 @@
```
- `-interactive` opens Claude Code with the task, so you can watch and steer. Leave it out for a headless run with the `implement` role's timeout and budget.
- Add `-review` (headless) to get a separate read-only review of the pull request it opens, or run it later with `factory run review-pr -repo dario/factory -pr <n>`.
- The agent may run `just check`, `go test`, `go vet`, `gofmt` and `go build` (`allowed_shell` in [`sandbox/factory-dev/factory.json`](../sandbox/factory-dev/factory.json)).
Author
Owner

since we are in a development sandbox, why are we even this strict about which commands the agent can run?

since we are in a development sandbox, why are we even this strict about which commands the agent can run?
@ -0,0 +35,4 @@
Then:
1. **Create a token** for that account, limited to the repositories the factory works on, with only the scopes in [tokens.md](tokens.md): on Forgejo `write:repository` and `write:issue`; on GitHub a fine-grained token with Contents, Pull requests and Issues read/write, Commit statuses and Metadata read. Give it a short lifetime. Keep it at hand for step 6; don't store it in a file.
Author
Owner

move the forge specific info into the tokens.md

move the forge specific info into the tokens.md
@ -0,0 +52,4 @@
Copy the template, then rename the kit after your project. Keep the kit's directory, its `.yaml` and its `.dockerfile` named alike, as in the template:
```sh
mkdir -p ~/.config/factory/projects
Author
Owner

this sounds super tedious. Could add a command to the factory tool that is meant to set up the profile via prompts? Maybe create an issue for that.

this sounds super tedious. Could add a command to the factory tool that is meant to set up the profile via prompts? Maybe create an issue for that.
@ -0,0 +67,4 @@
|---|---|
| `sbxenv.yaml` | The sandbox: the built-in `claude` workload, the kit, no host mount, a shell as entry point |
| `app/app.yaml` | The kit: tool versions, network rules, the forge credential, a setup hook |
| `app/app.dockerfile` | What the kit installs: your toolchain, OpenCode, `factory` and its config |
Author
Owner

there should probably be some sort of template for this, or users might be very lost

there should probably be some sort of template for this, or users might be very lost
@ -0,0 +68,4 @@
| `sbxenv.yaml` | The sandbox: the built-in `claude` workload, the kit, no host mount, a shell as entry point |
| `app/app.yaml` | The kit: tool versions, network rules, the forge credential, a setup hook |
| `app/app.dockerfile` | What the kit installs: your toolchain, OpenCode, `factory` and its config |
| `app/factory.json` | The factory configuration (no secrets) |
Author
Owner

the factory json content could also be prompted

the factory json content could also be prompted
@ -0,0 +196,4 @@
sbx env run ~/.config/factory/projects/app
```
`sbx` builds the kit and shows a plan: the network rules and the request to use the `app-forge` credential on `git.example.com`. Read it and approve. You land in a bash shell inside the sandbox.
2. **Sign in to Claude** (subscription only, once per machine): run `claude`, then `/login`, then exit Claude Code. The login stays on the host.
Author
Owner

this is too specific and may not be what the user needs

this is too specific and may not be what the user needs
dario merged commit acddc1c972 into main 2026-11-19 15:05:17 +01:00
dario referenced this pull request from a commit 2026-11-20 10:38:10 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dario/factory!25
No description provided.