Write a preset
For someone who shares settings across several repositories. A preset is a folder in a repository on your code host that holds the settings those repositories share (Use a preset). At the end a repository holds your preset, and others follow it.
Making the repository
-
Create a repository on your code host, or use one you have. It can have any name, and hold other things too. If you name it
factory-config,factory initfinds it without being told, in every repository of the same owner. For an organization,factory init --orgcreatesfactory-configwith a first preset in it. -
Write
factory-preset.yamlat its root. It takes the same settings as.claude/factory.yaml(Settings), except three, so a line moves between the two unchanged:version: 2 # the settings version, as in .claude/factory.yaml tickets: type: github board: 7 columns: backlog: Backlog refining: In refinement ready: Ready building: In progress review: In review done: Done code-host: type: github branch-name: "feature/{user}/{ticket}" rules: small-change-lines: 40 plugins: build: reviewers: - agent: acme-security-reviewer files: - src/**When the file's first line is a comment, as in
# The preset for every acme repository.,factory initshows that line beside the preset's name in the list it offers. -
Add the agents and skills its settings name in
agents/andskills/, besidefactory-preset.yaml, written the way your coding agent expects them (Your own skills and agents), and each approval policy's files inapproval-policies/NAME/(Approval policies).factory synccopies them into each repository that follows the preset. -
For a second preset in the same repository, such as one for Node repositories, add a folder with its own
factory-preset.yaml, and its ownagents/andskills/if it needs them. Its name is the repository's,//, and the folder:acme/factory-config//node.acme/factory-config ├── factory-preset.yaml # the preset acme/factory-config ├── agents/ │ └── acme-security-reviewer.md ├── skills/ │ └── acme-refine/SKILL.md └── node/ └── factory-preset.yaml # the preset acme/factory-config//node
A preset has no version of its own, and says nowhere which versions of
the factory it works with. A factory refuses a settings file with a key
it does not know, and names the key, so a preset written for a newer
factory stops factory preset add and factory update, with that key's
name.
The ticket system is set through a company preset
A company, or any organization, whose repositories share one ticket
system and one board puts tickets in its
preset, as the file above does: the system, the board's number, and its
columns. Every repository that follows the preset then has its tickets
on that board, factory init asks
none of them about tickets or a board, and one poller starts the builds
of all of them (The poller). The preset that
factory init --org writes for an organization is one of these.
Presets stay optional. A repository that follows none writes tickets
in its own .claude/factory.yaml.
What a preset can't set
Three settings belong to each repository:
repository, and
auto-merge.allow and auto-merge.commands.
Each one decides who a session takes instructions from or what merges
without a person. If a preset could set auto-merge.allow, one update
could let changes merge themselves in every repository at once.
A preset also can't name another preset. Each repository lists every preset it follows, so the order is in one place, and adding one never brings in another.
Checking and releasing
In a checkout of the preset's repository, run:
factory preset checkIt prints each preset it found and what it ships, so you can see a preset in a folder was picked up:
factory-preset.yaml 1 agent, 1 skill
node/factory-preset.yaml no agents or skillsIt worked when it lists every preset and nothing else. A problem gets a line saying what to change, and the command fails. One is a setting a preset can't set:
node/factory-preset.yaml: auto-merge.allow: a preset can't set this. Remove it, and set it in each repository that wants itAnother is a value no repository could use, such as a pattern written
without its quotes, as branch-name: {ticket}. The check prints the first
of these in each file, so run it again after you fix one:
factory-preset.yaml: code-host.branch-name: is a map, not a pattern. Quote it: branch-name: "{ticket}"A setting the preset leaves out is not a problem, even when a setting it
does write needs it. A preset can list the reviewer
factory-ui-reviewer, which needs to know how to start your website, and
leave site to each repository that follows it
or to another preset.
In an organization's factory-config, the command also compares the
schedule of .github/workflows/factory-poller.yml with
builds.poll-minutes in the preset beside
it, and fails when they differ: the poller runs on the file's schedule,
and factory status in each repository takes the interval from the
preset:
✗ .github/workflows/factory-poller.yml runs on "*/5 * * * *", and builds.poll-minutes is 30. Write "*/30 * * * *" there.A plugin that names an agent or a skill the repository doesn't ship gets a note, not a failure, since a repository that follows the preset can provide it:
factory-preset.yaml: plugins.build.reviewers: acme-docs-reader: not shipped here, so each repository that uses this preset must provide itThen merge it. A merge into the default branch is the release: each repository that follows the preset gets a pull request at its update job's next run, as When a preset changes describes. Who may merge into that repository decides what every repository that follows it is offered.
There is no way to offer a change to one repository before the rest. To
try one first, put it in a folder of its own, such as next/, and
follow acme/factory-config//next from the repository you try it in.