The Factory Architect is a set of instructions your coding agent follows to write a factory that fits how your team already works, and to test it on your last merged pull requests before you rely on it.
Before you start
- The
kilnCLI works in your repository (npx @kiln/cli, orpnpm kilnin this repository). - The GitHub CLI is logged in (
gh auth login), so the agent can read merged pull requests. - Optional: your coding agent has MCP servers for your tracker (Linear, Jira) and chat (Slack). The agent asks before it reads them.
1. Install the instructions
kiln architectThis writes .kiln/architect.md, the agent-neutral instructions, and a native wrapper for each coding agent the repository already uses:
| Agent | Wrapper | How to start |
|---|---|---|
| Claude Code | .claude/skills/kiln-architect/SKILL.md |
/kiln-architect |
| Cursor | .cursor/rules/kiln-architect.mdc |
Ask the agent to use the kiln-architect rule |
| GitHub Copilot | .github/prompts/kiln-architect.prompt.md |
Run the kiln-architect prompt |
| Codex, Gemini CLI, others | none needed | "Follow .kiln/architect.md" |
Pick wrappers with --agent claude,cursor,copilot or --agent all. Existing files are kept unless you pass --force. kiln architect --print writes the instructions to stdout for any other tool.
2. Let the agent work
The agent follows eight steps:
- Profile the repository with
kiln scan --json: languages, package manager, install, test, lint, typecheck and build commands, CI, agent instruction files, and MCP servers your dependencies suggest. - Learn from merged pull requests: typical size, recurring review asks, how tests are written, who reviews.
- Learn where work comes from, after asking you: tracker projects, labels and states, Slack channels where requests arrive, error volume.
- Write the factory under
kiln/, starting from a template: factory.yaml, agents with your real commands, a conventions skill from your review history, automations for your real sources, gates, scorers, a runner and MCP servers. - Backtest with
kiln bench from-prs. - Validate with
kiln validate kilnuntil it prints ok. - Explain every choice and its evidence in
kiln/FACTORY.md, with the secrets and connections you still need to add. - Ask before applying: it shows
kiln diffand runskiln applyorkiln connectonly after you say yes.
The agent never copies secrets, customer data or private messages into files; it writes patterns.
The backtest
kiln bench from-prs --repo acme/web --limit 20 --dir kilnReads your recent merged pull requests with the GitHub CLI and writes kiln/benchmarks/backtest/:
- One task per pull request, starting at the PR's base commit (
startingRepoRefs). - The prompt is the linked issue when the PR closes one, otherwise the PR's title and problem description. The diff is never included.
- Success criteria come from an "Acceptance criteria" section or checklist in the PR or its linked issue, otherwise from one default criterion.
criteriaVisibility: judge, so the agent can't read the answer, andreferencePrpoints at the merged PR.- Tags
xs,s,morlby changed lines. Bot pull requests, reverts and PRs without a base commit are skipped and listed.
Run it with kiln bench run backtest --factory <alias> once the factory is applied, and compare models by adding configurations to suite.yaml.