Skip to content
raulshPublic

About

Takes units of work from feedback to merged pull requests by driving Claude Code headless

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

tfy (thefactory)

tfy, short for thefactory, takes a unit of work (a feature, bug fix, improvement or chore) from an idea to a merged pull request. Every step is carried out by Claude Code, running headless on your machine.

 feedback ─▶ definition ─▶ planning ─▶ executing ─────────────────▶ release
 (Slack)     requirement    spec with    develop → PR(s) → review     CI, notes
             you approve    acceptance   → you merge
                            criteria
  • Definition. Claude writes the requirement: what is needed, and why. You edit it, or ask for a revision, then mark it ready.

  • Planning. Claude reads the linked repositories and writes a spec with numbered acceptance criteria. You approve it.

  • Executing. Claude implements the spec in isolated checkouts and commits locally. tfy pushes the branches and opens the pull requests, across as many repositories as the spec touches.

  • Review. A reviewer run checks each acceptance criterion against the diff. If any criterion is unmet or a finding blocks, the work goes back to development automatically, for a limited number of rounds. Once the pull requests are open you can Request changes yourself, even after the review approved. Claude makes them as your request, beyond the spec if need be, and the next review counts them as asked for. Back to merge undoes a review you asked for by mistake, as long as the pull requests haven't changed since the approval.

  • Merge. You merge from the UI, and a merge run takes it from there: it decides the order, and tfy checks each pull request before merging it (unchanged since the review, green, no conflicts). You can also merge on GitHub; tfy notices. If GitHub's rules for the base branch refuse the merge, for example because it needs an approval, tfy hands the unit back to you. You can then tick Merge as an administrator to bypass the rules (gh pr merge --admin) for that merge only.

  • Release. Claude writes release notes for users, and tfy follows CI on each merge commit. If CI fails, it offers a follow-up bugfix unit.

  • Feedback. Units can also start from Slack. tfy polls your channels through slk and triages every new message:

    • actionable ones become proposals for you to accept;
    • messages about tracked work are attached to it;
    • the rest is set aside as noise.

    You can also pick messages in the Inbox and turn them into a unit yourself.

It runs locally. tfy serve is the backend and serves the UI on 127.0.0.1; tfy serve --host 0.0.0.0 (or host: 0.0.0.0 in ~/.tfy/config.yaml) serves it to your private network too.

Requirements

  • Claude Code 2.1+, signed in (claude auth login), or accounts with their own token, key or Bedrock profile (see Accounts)
  • GitHub CLI, signed in (gh auth login)
  • git
  • slk, signed in (slk configure); optional, needed only for Slack feedback intake
  • To build: Go 1.26 and pnpm

Install

Every release has a .deb and a tarball for Linux, amd64 and arm64. Swap amd64 for arm64 below as needed.

# Debian and Ubuntu
gh release download -R raulsh/tfy -p '*_amd64.deb'
sudo apt install ./tfy_*_amd64.deb

# Any Linux: the binary alone, into ~/.local/bin
gh release download -R raulsh/tfy -p '*_linux_amd64.tar.gz'
tar -xzf tfy_*_linux_amd64.tar.gz -C ~/.local/bin tfy

From source, make install builds the UI and the binary into ~/.local/bin.

Quick start

tfy init         # creates ~/.tfy (moves ~/.thefactory there, if you used the old name)
tfy doctor       # checks claude, gh, git, slk
tfy serve --open # prints a link with a token, and opens it
  1. Create a project, link its GitHub repositories, and optionally its Slack channels (Projects → Slack).
  2. Create a unit, or accept a proposal from the Inbox, and follow its runs live.
  3. At each gate, decide:
    • mark the requirement ready;
    • approve the spec;
    • merge once the review approves.

To try the whole pipeline without spending tokens or touching GitHub, run make demo. It serves on port 7430 against fake claude and gh and a local "GitHub". Link acme/app to a project to start.

Accounts

Runs sign in with accounts, set up in Settings → Accounts: more than one subscription to spread usage, or Amazon Bedrock. On a new install there is one, this machine's Claude login: the claude login and the provider its settings choose, as before.

  • Subscription token: run claude setup-token with that subscription, and paste the token into tfy. Serving tfy on your network? Run tfy account secret <id> on the server instead: a token typed in the browser crosses the network in plain HTTP.
  • Amazon Bedrock: a region, and an AWS profile or a Bedrock API key. A profile allowed only bedrock:InvokeModel* is safest. Each model alias (opus, sonnet, haiku, fable) can map to a Bedrock model; fable refuses there, so map it to Opus.
  • API key.

Secrets stay in ~/.tfy/accounts, readable by you alone, never in the database or in the API's answers. Runs get their account's credentials, and nothing else: an inherited ANTHROPIC_API_KEY or the provider in your Claude Code settings cannot sign a token account in elsewhere. The agent's shell commands, and the tests they start, see no model credentials at all.

Which account runs what. A list of accounts, in order of preference, plus per stage an account, model and effort level: globally under Settings → Run stages, and per project in its Accounts tab, which wins. A new unit can override any stage too. A stage without an account runs on the first one in the list, and the config file still sets each stage's budget and time limit.

Usage limits. When an account reaches its limit, tfy pauses it until its reset and the run carries on with the next account in the list, in the same session if it had got anywhere. A session does not move between providers, say a subscription and Bedrock: there the run starts over, told that some of the work may be done. When every account is limited, the unit waits, and work resumes as soon as one frees up. Resume now on an account, or Retry on a unit, tries again at once.

Conventions

Projects want consistency: how commits are written, how pull requests are opened and described, how code is tested. Claude Code already knows how to follow such rules, so tfy does not reinvent them. It keeps them where Claude Code reads them, and makes its runs load them the way a session started in the repository would.

  • In each repository, versioned and reviewed with the code, so people using Claude Code by hand follow the same rules:
    • CLAUDE.md for what every session must know, and .claude/rules/*.md for topics or areas (paths: frontmatter scopes a rule to matching files);
    • hooks in .claude/settings.json, with scripts in .claude/hooks/, for checks that must never be skipped, like rejecting a commit message that breaks the rules;
    • attribution in .claude/settings.json; where a repository doesn't set it, tfy's runs add no Co-Authored-By trailer;
    • the pull request template, .github/pull_request_template.md.
  • Across a project, for rules its repositories share: the project's Conventions tab in tfy.

Before every run, tfy writes the unit workspace's CLAUDE.md, which holds the project's conventions and imports each checkout's CLAUDE.md and always-on rules, and its .claude/settings.json, with the repositories' hooks and attribution. Claude Code does the rest itself: path-scoped rules, nested CLAUDE.md files and imports. Claude writes the commit messages and the pull request title and description following those conventions; tfy only pushes and opens the pull request with them. Branch names follow the project's template (Pipeline tab, tfy/u{seq}-{slug} by default).

Hooks run outside the permission system, so tfy only takes them from the default branch, the reviewed version. It leaves a repository's hooks out of a run when that checkout's .claude/hooks differs from the default branch, and says so in the unit's activity.

They improve unit after unit. When a unit is done, a retrospective run looks at what went back and forth: review rounds, what people asked to change, comments on the pull requests, refused commands, failed CI. If that shows a gap in the conventions, it opens a unit (origin retrospective) proposing the change to CLAUDE.md, a rule, a hook or the pull request template. You accept or reject it like any proposal, and an accepted one lands as a reviewed pull request in the repository. The Conventions tab shows what each repository has today, and Propose a change starts such a unit by hand. Turn retrospectives off per project in the Pipeline tab.

Changes that merge in order

Some changes across repositories cannot merge at once. A shared module has to be merged before the repositories that use it can pin its merged commit. A service has to be deployed before the clients that need it. The plan run then writes a Merge order section in the spec: what merges first, what the rest waits for, and what must change in them once it is so, such as "pin github.com/acme/api to the commit it merged as".

The whole change is developed and reviewed at once, as usual. Where one repository depends on another, development pins that repository's commit on the unit's branch. When you click Merge, a merge run takes over. It reads the spec and the repositories, then decides each next step:

  • merge some pull requests together: all of them at once when nothing needs an order;
  • update open pull requests for what merged, such as moving a pin from a branch commit, which a squash merge leaves behind, to the merge commit or its tag. The run makes the change in the checkouts and tests it. tfy pushes it and reviews the update on its own, and a review that asks for changes goes back to the merge run;
  • wait until what merged is released (CI, deploys included, is green on its merge commits) or tagged (a tag contains them);
  • stop when it cannot go on safely, and hand the unit back to you.

tfy carries out each decision and tells the run what happened, until everything is merged. The run can change checkouts as a development run can, but it can neither merge nor push: tfy does both, with the same checks as always. The Merge card on the Execution tab lists its decisions. Release notes and the retrospective come once everything is merged.

The unit's repositories are available as dependencies. Agents have no credentials, so private repositories would be out of reach as dependencies. Each run's git config serves github.com/<owner>/<repo> URLs from the unit's checkouts, which hold its branches, the default branch as last fetched, and tags. tfy also adds them to GOPRIVATE. go get github.com/acme/api@<commit>, or an npm or pip git dependency, then works for a commit merged a minute ago or one that only exists on the unit's branch. Pushes through those URLs go nowhere, and the guard blocks pushes anyway.

GitHub issues

A unit can be linked to GitHub issues: create it from one (New unit → GitHub issue, or paste a link), or link it on the unit page.

  • Claude reads them. The define run gets each issue and its comments, fenced as information rather than instructions. Every later run finds the full text in the workspace's docs/issues/. Agents have no GitHub access, so tfy reads the issues with your gh.
  • GitHub links and closes them itself. Each pull request references the unit's issues: Closes #12, so merging closes the issue, or Refs #12 when you switch off closes on merge for that issue. tfy doesn't repeat a reference Claude already wrote. For an issue that must stay open, it turns Claude's Fixes #12 into addresses #12.
  • tfy can suggest how an issue could say more. Suggest improvements weighs the issue against what tfy has gathered: the Slack reports behind the unit, the requirement and spec, the pull requests and the release notes. Claude answers either "nothing to add", or a comment and, when the issue is unclear, a better title and description. You edit the suggestion and post it with your account, or dismiss it.
    • For public repositories the check leaves out who said what in Slack, and anything internal.
    • An edit is refused if the issue changed on GitHub after the check read it.
    • The Pipeline tab can run the check automatically once a requirement is marked ready. It still posts nothing on its own.

How agents are kept in their lane

Each Claude run gets only what its stage needs, and several layers stop it from publishing on its own:

  • Isolated checkouts. Every unit works in its own git clone --local checkouts, with no remote. Only tfy pushes and opens pull requests, using your credentials.

  • No publishing credentials. Runs start from a scrubbed environment: no GH_TOKEN, no SSH agent, an empty gh configuration, and a gitconfig with no credential helper. The CLI gets its account's credentials, which the agent's shell commands start without.

  • A guard hook. Every shell command passes through tfy hook-guard, which parses it and blocks pushes, remote and credential changes, and gh. It catches git -C, sh -c, eval, wrappers, and command substitutions. If the guard fails to run, the run is aborted, because the CLI itself would fail open.

  • Isolated settings. A unit's runs load only the workspace as a Claude Code project (--setting-sources project), whose settings tfy rewrites before every run; user settings, MCP servers (strict, none) and anything an agent left in the workspace's .claude stay out. Each run has an explicit tool list and a permission mode per stage:

    Stage Mode Access
    define dontAsk writes docs/ only
    plan dontAsk writes docs/ only; read-only commands
    develop auto the checkouts
    review, retrospective dontAsk read-only commands
  • Two human gates. No code is written until you approve a spec, and nothing merges until you do.

  • Local server. It binds to 127.0.0.1 unless you choose another host, checks Host (against DNS rebinding) and Origin, and requires a per-install token. Served to the network, it admits IP addresses and this machine's name as Host, and talks plain HTTP: the printed link is the only key, so use it only on networks you trust.

docs/spike.md records how the Claude Code CLI behaved when all of this was checked.

Development

make dev    # Go server with --dev on :7420, plus Vite on :5174 with hot reload
make test   # go test -race, tsc, biome
make demo   # full pipeline on fakes

To release, push a tag: git tag v0.1.0 && git push origin v0.1.0. The release workflow runs the tests, then GoReleaser (.goreleaser.yaml) builds the binaries and .deb packages and publishes them with a changelog. goreleaser release --snapshot --clean builds the same locally, into dist/.

Path What it holds
cmd/tfy Entry point.
internal/claude Runs claude -p: args, isolated env, stream parser, and a safety monitor that aborts on guard failures, the wrong permission mode, or pushes.
internal/guard The PreToolUse guard: a shell parser plus rules.
internal/pipeline Every stage (triage, define, plan, develop, publish, review, merge, release), managed clones and checkouts, the pollers, and restart recovery.
internal/slack The slk adapter. It reads the --json envelope, so truncation is never silent.
internal/jobs SQLite-backed job queue: one active job per unit, a boot sweep, and rate-limit pauses.
internal/store SQLite with goose migrations; sqlc queries live in queries/.
internal/api Fiber v3 JSON API, SSE streams, and the embedded UI.
ui React 19, antd 5, TanStack Query. The design follows groundcover.

Data lives in ~/.tfy, or $TFY_HOME:

  • tfy.db, the database
  • repos/, fetch-only bare clones
  • workspaces/<unit>/, the unit's documents and checkouts
  • config.yaml, models, budgets and timeouts per stage

About

Takes units of work from feedback to merged pull requests by driving Claude Code headless

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages