Project repository
Storage links here when the project folder is not a Git repository, and delivery reads it before picking a base commit. This file owns the repository requirement, the project settings record, how a delivery base is resolved and how agents write comments on pull requests.
A Git repository is required
Every factory project is a Git repository, either local-only or with a remote. Git keeps the history of product changes, and storage keeps the catalog in the shared Git directory, so there is nothing to record into without one.
If git rev-parse --path-format=absolute --git-common-dir fails in the project folder:
- Read-only and unattended skills (
tasks,feedback) andmigratereport that the folder is not a Git repository and stop. They create nothing. - An interactive skill that writes records explains the requirement and offers to set the repository up. Without the developer's explicit approval it stops, before creating the catalog or any file.
Set up an approved repository like this:
- Confirm the folder is the project root, not a parent of it such as the home directory.
- Run
git init, thengit symbolic-ref HEAD refs/heads/<branch>with the branch the developer names (proposemain). - List what the base commit would contain with
git status --short --untracked-files=all. Point out likely secrets (.env, keys, credentials) and dependency or build output (node_modules/,dist/) that is not ignored, and propose.gitignoreentries for them. Get the developer's confirmation of the final list. - Stage the confirmed paths explicitly and make the base commit, for example
Initial commit(--allow-emptywhen the folder has nothing to commit yet). If Git has nouser.nameoruser.email, ask the developer to set them; do not set an identity yourself. - Write the project settings with
repository: local-onlyand the branch asintegration_branch, then continue the original skill.
Never commit before the developer confirms the list, and never add a remote yourself.
Project settings
The developer states, once per project, how the repository is used. Record it in $FACTORY_ROOT/settings.md, in the catalog next to tasks/:
---
repository: remote # remote | local-only
remote: origin # null when local-only
integration_branch: main
pull_requests: on # on | off; ignored when local-only
---
## App sandbox
`<id>` is the full task ID; pick free ports for `<db-port>` and `<app-port>`.
- Start: `docker compose -p factory-<id> up -d db` (published on `<db-port>`), then `DATABASE_URL=postgres://localhost:<db-port>/app npm run db:migrate && npm run db:seed`, then `PORT=<app-port> npm run dev`
- Stop: stop the dev server, then `docker compose -p factory-<id> down -v`
## Baseline decisions
- 2026-11-16: `npm run format:check`, files under `.agents/factory/` and `.agents/skills/factory-*/`: ignore (developer)
## Known noise
- 2026-11-17: `npm run build`, "Next.js advisory check failed": retry once (developer)
- Never infer
repositoryfromgit remote; you may propose values from it, but the developer confirms them. When the settings are missing, the first skill that needs them (code or prototype delivery) asks and writes them. - If the repository no longer matches the settings (for example, a remote was added to a
local-onlyproject, or the named remote or branch is gone), ask the developer before changing the settings or delivering. pull_requestssays whether delivery pushes the task branch and opens a PR at the end. It defaults toonwhen missing.- App sandbox says how to run an isolated instance of the app for the STR run when the project's docs don't: how to start and stop its own services and data on free ports. Delivery asks and adds it the first time it needs it.
- Baseline decisions are standing answers to the baseline check. Add one only when the developer says the decision should apply to future deliveries. Each line names the check, the paths, tests or rule IDs it covers, the decision (
ignoreorwaive) and the date. It covers a failure only when the failure is within those paths, tests or rules. - Known noise lists toolchain failures that are not caused by the change and pass when run again, such as an advisory check that fails a first build. Each line names the check, the message it prints,
retry onceand the date. The gate re-runs such a check once. Add one only when the developer says so. A missing section means none. - Edit the settings only while holding the
locks/settingslock, taken and released like the journal lock in storage, and re-read before writing.
Resolve the delivery base
Code delivery and mocked-prototype delivery start from the integration branch in the settings, unless a code task is stacked on another code task's branch.
- local-only: use the local
integration_branchhead. Do not fetch. - remote: reach the recorded remote, then pick the base from what it has.
Connect. Run
git ls-remote --heads <remote>. If it fails over SSH, retry once over HTTPS withghcredentials, using the real hostname (resolve an~/.ssh/configalias withssh -G <alias>) and the same repository path. Do this only ifgh auth status --hostname <host>shows a login, and never change the remote URL or the developer's SSH configuration:git -c credential.helper='!gh auth git-credential' ls-remote --heads https://<host>/<owner>/<repo>.gitIf no method connects, stop and report the commands and their errors. Never fall back to a stale remote-tracking ref or the local branch because of a connection or authentication failure.
Empty remote. If the remote lists no branches at all, use the local
integration_branchhead and tell the developer.Missing branch. If it lists branches but not
integration_branch, ask; the recorded branch may be wrong.Otherwise fetch the branch with the method that connected, for example
git -c credential.helper='!gh auth git-credential' fetch https://<host>/<owner>/<repo>.git "+refs/heads/<branch>:refs/remotes/<remote>/<branch>", and use the updated remote-tracking commit. If the fetch fails, stop as in step 1.
Record the ref the base came from as delivery.base_ref in the task record: for example origin/main, main (local-only) or main (local, remote empty).
Check whether the base moved
The branch a delivery started from can move on while the task is built and reviewed, for example when another task's PR is merged. Delivery checks it at finish and before pushing, so a task is not finished or pushed on a stale base without the developer knowing.
- Get the current tip of the branch named in
delivery.base_ref, from where it says the base came from: a local branch forlocal-onlyor another(local, ...)ref, otherwise fetch it with the method that connects, and stop as in resolve the delivery base if none does. For a stacked task whose parent's branch was deleted, use the tip that section's fallback gives instead of stopping. A base recorded as(local, remote empty)is checked against the remote branch if it exists by now. A record withoutbase_ref, from before it existed, uses the settings' integration branch the same way; if the task's log or the developer says it was built on another branch, ask which one. - Find the newest base commit the branch already contains:
git merge-base HEAD <tip>. When it differs fromdelivery.baseanddelivery.baseis its ancestor, the branch took in newer base commits some other way, for example through the host's Update branch button. Report it so delivery can record it. - If
git merge-base --is-ancestor <tip> HEADsucceeds, the base hasn't moved, or the branch already contains the new commits. - Otherwise collect for the developer:
- the new commits:
git log --oneline <base>..<tip>, - the files changed both there and in the task: the overlap of
git diff --name-only <base> <tip>andgit diff --name-only <base> HEAD, - whether the task's own changes apply to the tip without conflicts:
git merge-tree --write-tree --merge-base <base> <tip> HEADexits0when they do. This previewsgit rebase --onto <tip> <base>as one change; the rebase replays each commit, so it can still stop where the preview doesn't.
- the new commits:
Deliver decides what to do with the result. The check may fetch and may write Git objects, but it leaves the task branch and its worktree untouched.
Comments on pull requests
Anything an agent writes on a pull request or in its review threads (a comment, a review comment, a reply) starts with one quoted line naming the model that wrote it, so it can't be mistaken for the developer's own:
> 🤖 Claude Opus 5.5 comment
Use the model's name as the agent knows it, never the developer's name.
When the text gives feedback on the change, write it as a Conventional Comment: <label> [(decorations)]: <subject>, then any discussion on the lines below. Labels include praise, nitpick, suggestion, issue, todo, question, thought, chore and note; mark whether it holds up the change with (blocking) or (non-blocking). For example:
> 🤖 Claude Opus 5.5 comment
issue (blocking): the retry loop never stops when the server returns 500.
`fetchWithRetry` only counts 429 responses, so a 500 retries forever.
A reply that only reports what was done names the commit, for example note: fixed in abc1234.
Agents post on a PR only when the developer asks or a skill step says to. The PR description is not a comment: deliver writes it in its own format.
Original Markdown, including metadata
# Project repository
[Storage](storage.md) links here when the project folder is not a Git repository, and delivery reads it before picking a base commit. This file owns the repository requirement, the project settings record, how a delivery base is resolved and how agents write [comments on pull requests](#comments-on-pull-requests).
## A Git repository is required
Every factory project is a Git repository, either **local-only** or with a **remote**. Git keeps the history of product changes, and [storage](storage.md) keeps the catalog in the shared Git directory, so there is nothing to record into without one.
If `git rev-parse --path-format=absolute --git-common-dir` fails in the project folder:
- Read-only and unattended skills (`tasks`, `feedback`) and `migrate` report that the folder is not a Git repository and stop. They create nothing.
- An interactive skill that writes records explains the requirement and offers to set the repository up. Without the developer's explicit approval it stops, before creating the catalog or any file.
Set up an approved repository like this:
1. Confirm the folder is the project root, not a parent of it such as the home directory.
2. Run `git init`, then `git symbolic-ref HEAD refs/heads/<branch>` with the branch the developer names (propose `main`).
3. List what the base commit would contain with `git status --short --untracked-files=all`. Point out likely secrets (`.env`, keys, credentials) and dependency or build output (`node_modules/`, `dist/`) that is not ignored, and propose `.gitignore` entries for them. Get the developer's confirmation of the final list.
4. Stage the confirmed paths explicitly and make the base commit, for example `Initial commit` (`--allow-empty` when the folder has nothing to commit yet). If Git has no `user.name` or `user.email`, ask the developer to set them; do not set an identity yourself.
5. Write the project settings with `repository: local-only` and the branch as `integration_branch`, then continue the original skill.
Never commit before the developer confirms the list, and never add a remote yourself.
## Project settings
The developer states, once per project, how the repository is used. Record it in `$FACTORY_ROOT/settings.md`, in the catalog next to `tasks/`:
```markdown
---
repository: remote # remote | local-only
remote: origin # null when local-only
integration_branch: main
pull_requests: on # on | off; ignored when local-only
---
## App sandbox
`<id>` is the full task ID; pick free ports for `<db-port>` and `<app-port>`.
- Start: `docker compose -p factory-<id> up -d db` (published on `<db-port>`), then `DATABASE_URL=postgres://localhost:<db-port>/app npm run db:migrate && npm run db:seed`, then `PORT=<app-port> npm run dev`
- Stop: stop the dev server, then `docker compose -p factory-<id> down -v`
## Baseline decisions
- 2026-11-16: `npm run format:check`, files under `.agents/factory/` and `.agents/skills/factory-*/`: ignore (developer)
## Known noise
- 2026-11-17: `npm run build`, "Next.js advisory check failed": retry once (developer)
```
- Never infer `repository` from `git remote`; you may propose values from it, but the developer confirms them. When the settings are missing, the first skill that needs them (code or prototype delivery) asks and writes them.
- If the repository no longer matches the settings (for example, a remote was added to a `local-only` project, or the named remote or branch is gone), ask the developer before changing the settings or delivering.
- **`pull_requests`** says whether delivery pushes the task branch and opens a PR at the end. It defaults to `on` when missing.
- **App sandbox** says how to run an isolated instance of the app for the [STR run](deliver/SKILL.md#5-verify-the-running-app) when the project's docs don't: how to start and stop its own services and data on free ports. Delivery asks and adds it the first time it needs it.
- **Baseline decisions** are standing answers to the [baseline check](deliver/SKILL.md#baseline-check). Add one only when the developer says the decision should apply to future deliveries. Each line names the check, the paths, tests or rule IDs it covers, the decision (`ignore` or `waive`) and the date. It covers a failure only when the failure is within those paths, tests or rules.
- **Known noise** lists toolchain failures that are not caused by the change and pass when run again, such as an advisory check that fails a first build. Each line names the check, the message it prints, `retry once` and the date. The gate [re-runs such a check once](deliver/SKILL.md#sort-a-failure). Add one only when the developer says so. A missing section means none.
- Edit the settings only while holding the `locks/settings` lock, taken and released like the journal lock in [storage](storage.md), and re-read before writing.
## Resolve the delivery base
Code delivery and mocked-prototype delivery start from the integration branch in the settings, unless a code task is [stacked](deliver/SKILL.md#stacked-tasks) on another code task's branch.
- **local-only:** use the local `integration_branch` head. Do not fetch.
- **remote:** reach the recorded remote, then pick the base from what it has.
1. **Connect.** Run `git ls-remote --heads <remote>`. If it fails over SSH, retry once over HTTPS with `gh` credentials, using the real hostname (resolve an `~/.ssh/config` alias with `ssh -G <alias>`) and the same repository path. Do this only if `gh auth status --hostname <host>` shows a login, and never change the remote URL or the developer's SSH configuration:
```sh
git -c credential.helper='!gh auth git-credential' ls-remote --heads https://<host>/<owner>/<repo>.git
```
If no method connects, stop and report the commands and their errors. Never fall back to a stale remote-tracking ref or the local branch because of a connection or authentication failure.
2. **Empty remote.** If the remote lists no branches at all, use the local `integration_branch` head and tell the developer.
3. **Missing branch.** If it lists branches but not `integration_branch`, ask; the recorded branch may be wrong.
4. **Otherwise** fetch the branch with the method that connected, for example `git -c credential.helper='!gh auth git-credential' fetch https://<host>/<owner>/<repo>.git "+refs/heads/<branch>:refs/remotes/<remote>/<branch>"`, and use the updated remote-tracking commit. If the fetch fails, stop as in step 1.
Record the ref the base came from as `delivery.base_ref` in the [task record](task-record.md): for example `origin/main`, `main (local-only)` or `main (local, remote empty)`.
## Check whether the base moved
The branch a delivery started from can move on while the task is built and reviewed, for example when another task's PR is merged. Delivery checks it at [finish and before pushing](deliver/SKILL.md#6-finish), so a task is not finished or pushed on a stale base without the developer knowing.
1. Get the current tip of the branch named in `delivery.base_ref`, from where it says the base came from: a local branch for `local-only` or another `(local, ...)` ref, otherwise fetch it with the method that connects, and stop as in [resolve the delivery base](#resolve-the-delivery-base) if none does. For a [stacked task](deliver/SKILL.md#stacked-tasks) whose parent's branch was deleted, use the tip that section's fallback gives instead of stopping. A base recorded as `(local, remote empty)` is checked against the remote branch if it exists by now. A record without `base_ref`, from before it existed, uses the settings' integration branch the same way; if the task's log or the developer says it was built on another branch, ask which one.
2. Find the newest base commit the branch already contains: `git merge-base HEAD <tip>`. When it differs from `delivery.base` and `delivery.base` is its ancestor, the branch took in newer base commits some other way, for example through the host's **Update branch** button. Report it so delivery can record it.
3. If `git merge-base --is-ancestor <tip> HEAD` succeeds, the base hasn't moved, or the branch already contains the new commits.
4. Otherwise collect for the developer:
- the new commits: `git log --oneline <base>..<tip>`,
- the files changed both there and in the task: the overlap of `git diff --name-only <base> <tip>` and `git diff --name-only <base> HEAD`,
- whether the task's own changes apply to the tip without conflicts: `git merge-tree --write-tree --merge-base <base> <tip> HEAD` exits `0` when they do. This previews `git rebase --onto <tip> <base>` as one change; the rebase replays each commit, so it can still stop where the preview doesn't.
Deliver decides what to do with the result. The check may fetch and may write Git objects, but it leaves the task branch and its worktree untouched.
## Comments on pull requests
Anything an agent writes on a pull request or in its review threads (a comment, a review comment, a reply) starts with one quoted line naming the model that wrote it, so it can't be mistaken for the developer's own:
```markdown
> 🤖 Claude Opus 5.5 comment
```
Use the model's name as the agent knows it, never the developer's name.
When the text gives feedback on the change, write it as a [Conventional Comment](https://conventionalcomments.org/): `<label> [(decorations)]: <subject>`, then any discussion on the lines below. Labels include `praise`, `nitpick`, `suggestion`, `issue`, `todo`, `question`, `thought`, `chore` and `note`; mark whether it holds up the change with `(blocking)` or `(non-blocking)`. For example:
```markdown
> 🤖 Claude Opus 5.5 comment
issue (blocking): the retry loop never stops when the server returns 500.
`fetchWithRetry` only counts 429 responses, so a 500 retries forever.
```
A reply that only reports what was done names the commit, for example `note: fixed in abc1234`.
Agents post on a PR only when the developer asks or a skill step says to. The PR description is not a comment: deliver writes it in its own format.