Skip to content
Software Factory

Build a Software Factory with Claude Code

Build a software factory on one repository: a rules file, a GitHub Actions workflow running Claude Code, branch protection and ticket status.

Seif Sgayer, founder. Published 2 October 2026, updated 5 November 2026. 7 min read.

To build a software factory with Claude Code, label a GitHub issue, let a GitHub Actions workflow run Claude Code in a clean runner, and let it open a pull request. CI tests it and a person approves the merge. The agent never merges.

This builds a small factory on one repository. Everything runs inside GitHub, with the ticket tool of your choice at the front. The real work is the rules file, the tests and the tickets. It is a light factory on purpose: the agent writes the first draft and a person decides (see light and dark software factories).

Claude Code is the agent here. It is live. Codex full delivery is still being verified, and Cursor has not been run live.

Prerequisites

Skip these and you get a factory that opens pull requests nobody trusts.

  • A GitHub repository whose test suite runs in CI on every pull request, with a one-line local command. Fix flaky tests first: the agent treats a flaky failure as a bug and chases it.
  • A Claude plan or API key with access to Claude Code.
  • Branch protection on main requiring one approving review, and the ability to add a required status check.
  • Tickets with written acceptance criteria. Three short bullets is enough.

The ticket tool here is GitHub Issues. Jira, ClickUp and Linear work the same way through their GitHub integrations or a webhook. The factory-ready checklist shows which prerequisites you already meet.

The steps

  1. Write the repository rules file. Create CLAUDE.md at the repository root: how to install, how to run tests, the conventions you enforce, the paths the agent must never touch. Keep it short and factual. It is read on every run and is the biggest lever on quality.
  2. Add a trigger label. Create a label such as factory. Agree that applying it means the factory may pick the issue up. Only people with triage permission can label, which is your first access control.
  3. Store the API key as a repository secret. It then never appears in the workflow file or logs. Scope the workflow token to the minimum: write on contents, pull requests and issues.
  4. Create the GitHub Actions workflow. Run it when an issue gets the trigger label. It checks out the repository, runs the official Claude Code action with the issue as the task, and asks for a new branch and a pull request that references the issue.
  5. Install the Claude Code GitHub integration. Follow the Claude Code GitHub Actions documentation, then run the workflow once on a trivial issue to see it end to end.
  6. Protect the main branch. Require one approving review and make the CI test job a required check. Now the pull request cannot merge until the suite passes and a person approves, whatever the agent does.
  7. Send status back to the ticket. Comment on the issue with the pull request link when the run ends. A second workflow on pull request close comments, and closes the issue on merge.
  8. Measure and tighten. Track the measures below. Use the first weeks to improve the rules file and the tickets, not to loosen the gate.

The repository rules file

Treat CLAUDE.md as the onboarding document for a careful contractor on day one.

  • Setup and test commands, exactly as typed. Not "run the tests" but the command itself.
  • Conventions the linter does not catch: naming, where new modules go, how errors are handled, what a commit message looks like.
  • Definition of done: tests added or updated, lint clean, a pull request description that lists the acceptance criteria met.
  • Forbidden areas: migrations, billing code, authentication, anything with a compliance owner. State the paths, and have the agent say so in the pull request when a ticket needs them.
  • Scope rules: one ticket, one pull request, no drive-by refactors, no dependency changes unless the ticket asks.

When the agent gets something wrong twice, add one line.

The GitHub Actions workflow

This is a skeleton. Action names, inputs and permissions change, so check the Claude Code GitHub Actions documentation. Placeholders are in angle brackets.

# .github/workflows/factory.yml  (skeleton, check the docs for current inputs)
name: factory
on:
  issues:
    types: [labeled]
permissions:
  contents: write
  pull-requests: write
  issues: write
  id-token: write
jobs:
  run:
    if: github.event.label.name == '<trigger-label>'
    runs-on: ubuntu-latest
    timeout-minutes: <limit>
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 1
      - name: Run Claude Code on the issue
        uses: anthropics/claude-code-action@<version>
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          prompt: |
            Work on issue #${{ github.event.issue.number }}.
            Title: ${{ github.event.issue.title }}
            Follow CLAUDE.md. Create a branch, make the change,
            run the tests, and open a pull request that references
            the issue and lists the acceptance criteria it meets.
          # Tool and turn limits go here. Keep them tight at the start.
      - name: Report back to the issue
        if: always()
        run: |
          gh issue comment ${{ github.event.issue.number }} \
            --body "Factory run finished: ${{ job.status }}. See the linked pull request."
        env:
          GH_TOKEN: ${{ github.token }}

Three details matter. The if condition means no other label starts it, so the factory only runs on purpose. The timeout caps how long a confused agent can run. The permissions block is everything the agent can do: push a branch and open a pull request. It cannot merge, because branch protection governs merging, not the token.

Run it once on a throwaway issue, then fix what the agent misunderstood in the rules file, not the prompt.

Branch protection and the review gate

The gate keeps a person responsible for main. Set three rules on the branch: require a pull request, require at least one approving review, and require the test job to pass. Turn off administrator bypass, or agree that nobody uses it for factory pull requests.

Review the agent's pull request as you would a new team member's. Read the diff and the test, and ask whether the acceptance criteria are met, not whether the code looks plausible. Agents are good at plausible.

If a pull request needs more than a small change, close it, improve the ticket or the rules file, and run again. Keep every change approved by a person until you trust the suite.

Status back to the ticket

The run comments with the pull request link or the failure. A second workflow, triggered when a pull request closes, closes the issue if it merged and comments if it did not. The test: a product manager should follow a ticket from backlog to done without opening GitHub.

What to measure

Measure from the first run. All three figures come from GitHub, with no dashboard.

MeasureWhere it comes fromWhat it tells you
Tickets turned into pull requestsLabel events against pull requests openedWhether tickets are specified well enough to finish
Check pass rateStatus checks on factory pull requestsWhether the rules file and the suite do their job
Time from ticket to pull requestLabel time to pull request timeWhere the queue is: runner, agent or review

Set no targets in the first month. Widen the kinds of work you label only when the pass rate on the current kind is boring.

Common questions

Can Claude Code run in GitHub Actions without a person present?

Yes. The official action runs on a hosted runner when an event such as a label fires, with the key held as a secret. It can push a branch and open a pull request. Merging stays under branch protection.

How do I keep the agent out of sensitive code?

Name the forbidden paths in the rules file and tell the agent to stop and report. Back that with a CODEOWNERS file so those paths need a named reviewer.

Where you need checks and people

This loop gives you drafts. It does not give you the ten-step method behind each one: analysis, a plan, Before and After checks, and a fresh reviewer. See how the factory runs each step, or compare how it sits next to your pipeline in software factory vs DevOps.

Next on the reading path

Agentic Software Factory, Explained

An agentic software factory lets AI agents, not assistants, do the work from ticket to pull request. Agentic says who works, not who approves.