facet

module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0

README

         /\
        /  \
       / /\ \
      /_/  \_\        f a c e t
      \ \  / /
       \ \/ /         one task, many repositories,
        \  /          one disposable view
         \/

facet

Task-scoped workspaces over many git repositories. A workspace is a directory that assembles several repositories into one view for one task — and because its whole layout is declared in .workspace.json, the directory is regenerable from the manifest. Nothing about it is precious.

That is the core, and it stands on its own: no GitHub, no issues, no agents — just a clean way to lay several repositories side by side and rebuild them anywhere. The issue-driven features further down grew on top of it and became mainstays, but the workspace is the thing.

~/Workspaces/
  delivery/               # a long-lived, topical workspace
    .workspace.json
    platform/             # a clone this workspace owns outright
    infra/
  iss-platform-67-…/      # an ephemeral workspace, one GitHub issue

Each entry is either a clone the workspace owns outright — its own branch, its own index, safe from every other workspace — or a link into a shared checkout, where one working tree is visible everywhere at once.

Why

Working several issues at once — yourself, or with agents in parallel — means fighting over one working tree: one branch, one dirty index. Giving each task its own checkout fixes that, and costs disk. facet makes the checkouts nearly free, and makes the throwaway ones disposable without losing work.

Install

go install github.com/bottega-cereghino/facet/cmd/facet@latest

macOS. Requires git. The issue features additionally use the gh CLI; reap also asks tmux and lsof, when they are installed, what is still running in a workspace. facet shells out to both, so it inherits your existing credentials, SSH agent and gh accounts, and never handles a token itself.

The core: workspaces

Everything here works with plain git repositories and needs nothing else.

facet new delivery --clone platform=git@github.com:acme/platform.git \
                   --clone infra=git@github.com:acme/infra.git
facet sync                 # idempotently rebuild; never touches an existing clone
facet ls                   # what is here, and is it healthy
facet restore              # a fresh machine: rebuild every workspace

new scaffolds the manifest and its entries; add and rm adjust them later. sync makes the directory match the manifest and is safe to run at any time — it creates what is missing and leaves what already exists alone. On a fresh machine, restore walks every workspace and brings them all back from their manifests. Run ls from a directory with no manifest of its own that holds workspace subdirectories — the workspaces root itself — and it lists every workspace under it with a rolled-up health summary, instead of erroring.

facet ls --size adds what deleting each workspace would free and whether facet reap would delete it now, with a total at the end:

WORKSPACE  ENTRIES  HEALTH  FREES  REAP
notes      0        ok      8K     held (1)
platform   1        ok      812M   reapable

812M in all; 1 reapable now, freeing 812M. `facet reap <name>` says what holds the rest.

It runs reap's own checks, so it fetches every clone and asks GitHub about open pull requests, and it is slower than a plain ls. The size counts disk blocks, and leaves out objects a clone shares with the mirror: deleting the workspace does not free those.

Working from GitHub issues

The workspace core turned out to be the perfect base for a second habit: opening a throwaway workspace for a single issue, ready to work in seconds. Two features grew here and became mainstays — inferring an issue's repositories, and generating a CLAUDE.md that hands an agent everything it needs to start.

facet spawn 67 --repo acme/platform

spawn reads the issue, works out which repositories it needs, prints why each one was chosen, and waits. On confirmation it creates an issue-linked branch (gh issue develop), clones each repo, and writes a CLAUDE.md carrying the issue body and the durable hazards recorded for its area/* labels. Then it stops and tells you where to work — opening an editor or starting an agent is yours.

The issues a workspace covers

The issues a workspace covers go in .scope, one owner/repo#n per line: the spawned issue always, plus any --scope owner/repo#n you pass, because one task regularly carries a small group of issues rather than exactly one. It is not versioned, and facet sync never touches it.

facet scope list prints it, found by walking up from the working directory so it works from inside a repository subdirectory. facet scope add, remove and set change it afterwards; add and remove are safe to repeat.

facet spawn 67 --repo acme/platform --scope acme/platform#68 --scope acme/tools#12
After the spawn

spawn sets the workspace up and stops: it prints where to work and runs nothing. Two options start something there, in this terminal, once the workspace is ready:

flag runs in the home clone
(none) nothing; spawn prints work in: <path> and exits
--claude claude, with Remote Control when routing's spawn.rc is true or --remote is given
--exec <command> /bin/sh -c <command>, with $FACET_WORKSPACE set to the workspace

--exec is how you open a multiplexer or an editor, the way you like it:

facet spawn 67 --repo acme/platform --exec 'tmux new-window -c "$PWD"'
facet spawn 67 --repo acme/platform --exec 'code .'

The launch runs last, and only on a complete workspace: if a clone failed, spawn says Workspace INCOMPLETE, names what is missing, launches nothing and exits non-zero. A launch that itself fails only warns, and leaves the ready workspace for you to open yourself. --claude and --exec together are refused before anything is created.

Remote Control makes the session reachable from another device over Anthropic's relay. It needs claude signed in via claude.ai OAuth and the workspace trusted once. The session is named after the workspace, attached as --remote-control=<name> (never as a positional argument, which a following prompt would make ambiguous). spawn.sessionNamePrefix in routing names the host.

facet does not open tmux itself. The old --attach, --no-attach, --session, --mux, --rc and --no-rc are still accepted, hidden and deprecated: --rc means --claude --remote, the others do nothing.

Which repositories, and why
acme/platform#67  Rehearse a database restore: nothing has ever been restored
  labels: P0-critical, area/backups, blocked

repos to clone, and why:
  platform    home; label:area/backups          [home, gets the branch]
  infra       blocked-by:acme/infra#41; label:area/backups

Labels cannot decide which repositories an issue needs. A label describes a topic, and the same topic label gets used in several repos. The decisive evidence is in the issue body: owner/repo#n cross-references, Blocked by lines, and — for issues filed through a form — an explicit "Repos in scope" field (or "Repos involved"), listing routing keys, aliases, owner/repo or repo URLs. When that field is filled in it wins over labels; an owner/repo routing does not know is named in the plan rather than silently dropped. The issue above is labelled area/backups with no Terraform label, and still cannot be closed without a change in another repository. So the inference is always shown, never silently trusted, and correctable with --clone / --add / --rm. Each of those takes a routing key or key=url, repeatably, and refuses a value it cannot resolve rather than skipping it — a discarded override and an applied one must not look the same. --dry-run prints it and creates nothing.

Moving the issue on a project board

A GitHub issue has no "in progress" state — it is open or closed. "In progress" is an option on the Status field of a Projects v2 board, and it belongs to the board item, not to the issue. So give .tools/routing.json a board to drive, and facet spawn puts the issue on it and sets the field once the workspace is real:

"project": { "owner": "acme", "number": 4, "statusField": "Status", "onSpawn": "In progress" }

The board is named, never by node ID: PVTSSF_lADOD… is stable but unreadable, and would rot in a config file without anyone noticing. facet resolves the names on each spawn, matching case-insensitively, and reports the transition:

+ project acme/4: Status = In progress

Both fields are optional and both are shown by --dry-run before anything happens. Omit project and no board is touched. A board that has been renamed, or a gh missing the project scope, warns and does not fail the spawn — the clones, the branch and the CLAUDE.md are the point, and a complete workspace is never stranded by GitHub Projects being briefly uncooperative.

The confirmed repo set is written back

facet spawn prints its inference and waits for you. That answer is worth keeping: on confirmation it records the confirmed repos in the issue's Repos in scope section, so the next spawn reads a decision (scope-field) instead of repeating a guess — and an issue never filed through a form finally declares what it touches.

+ issue body: Repos in scope = platform, infra

Rewriting someone's issue body is unforgiving, so the rewrite is timid: the neighbouring sections come back byte for byte, an existing heading keeps the level its author chose, an empty set writes nothing, and a body that already says the right thing is left alone — spawning twice does not churn the issue's history. The body is re-read immediately before the write, because the copy fetched at the top of spawn may be minutes old by then, and someone may have edited it since. --no-writeback opts out.

Filing an issue that the board can see
facet file --repo acme/platform \
  --title "gateway: last_login_at is never written" \
  --label P1-high --label area/security --label complexity/2 --label env/dev \
  --repos platform,gateway --body-file issue.md

facet file searches for a duplicate before it creates one — concurrent sessions file into the same repository, and closed issues count, because refiling something you decided against is the expensive kind of duplicate. Then it checks the title and the labels against the conventions block, reporting every violation at once, so a single filing tells you everything it needs rather than one rule at a time:

"conventions": {
  "titlePattern": "^[^:\\n]{2,60}: .+",
  "requireOneOf": {
    "priority":   ["P0-critical", "P1-high", "P2-medium", "P3-low"],
    "complexity": ["complexity/1", "complexity/2", "complexity/3"]
  },
  "requirePrefix": { "area": "area/" }
}

facet knows that some labels are required, never which ones. Omit the block and nothing is enforced. --repos is recorded in the body, so the first spawn of that issue is exact.

A ### Complexity section in the body, starting with a number (2, c2 or complexity/2), adds the complexity/N label, so the body and the labels agree and the conventions see it. A --label complexity/M that disagrees is refused. A repository that does not define the label gets the issue without it, and a warning. file prints the labels it applied after the URL.

Tidying up

facet issues lists the ephemeral workspaces. facet reap <name> deletes a workspace, ephemeral or long-lived, and refuses while there are unpushed commits, uncommitted changes, stashes, an open pull request, a live multiplexer session, or a tmux pane or process still in the workspace — the states where deleting would lose work, or delete a directory out from under something still running in it. A refusal lists every holder it can see, with a count, so clearing what it names and re-running should not turn up more.

A long-lived workspace can also hold files of its own beside its clones: notes, a CLAUDE.md. Any that are not committed in an enclosing repository (a versioned ~/Workspaces, say) hold it as well, because the workspace is their only copy. Links are removed, never followed, so their targets are untouched.

facet reap --reapable deletes every workspace at the root that reap would delete now. It lists them with the disk each frees and the total, asks once, and leaves every held workspace alone. It never forces, and it checks each workspace again just before deleting it, so work started while the prompt waited is not lost. facet ls --size shows the same list without deleting.

The issue graph was removed

facet-graph (tree and deps, for sub-issue hierarchies and blocked-by dependencies) was dropped after v0.2.0; go install …/cmd/facet-graph@v0.2.0 still builds the last version. facet file still records Blocked by edges when it files an issue.

Comments, by kind

facet comment last owner/repo#282 --kind plan

Where a decision is revised by posting it again, the newest one is what binds, and finding it by eye in a long thread is how the wrong revision gets acted on. A kind is a named regexp in the routing file's commentKinds; --grep needs no configuration. Anchor the pattern to the whole heading rather than to a word — ^#{1,6} +Plan\b, not ^#+ .*plan — because a loose one does not error, it silently returns an older comment as the latest. The match count is always printed so that is visible.

The credential preflight

Everything facet does on the forge rides one gh credential, shared with every other tool and agent session on the machine. That credential has been invalidated before with no announcement, and the fault was found mid-operation rather than up front.

facet preflight checks the credential surface before it is needed:

$ facet preflight
host        github.com
account     RiccardoCereghino
token type  ghp_ (value never read)
scopes      read:org, repo, workflow
protocol    ssh
source      /Users/cerre/.config/gh/hosts.yml

✓ credential preflight passed

It checks that gh is logged in and the account is active (and, with FACET_GH_ACCOUNT set, the expected one); that the token is not a gho_ OAuth-App token — GitHub issues one per (app, user) pair, so any other gh auth login anywhere silently invalidates it, which is what happened; that repo, read:org and workflow are all granted; that git's host-level protocol is ssh (gh auth login --with-token flips it to https silently, and gh config get git_protocol reports the global default, so it is the wrong thing to read); and that ~/.ssh/id_ed25519 exists and is not group- or world-readable, since that key authenticates every push.

facet spawn runs the same checks first, before routing and before the issue lookup, and warns about each problem rather than refusing. It leaves out the token-type rule: a default gho_ token breaks nothing about a spawn, so only facet preflight reports it. A credential that cannot reach GitHub at all fails at the issue lookup, before anything is created. The workspace core (new, add, sync, restore) never consults the credential.

The account check is opt-in: set FACET_GH_ACCOUNT to the login the credential must belong to.

Two properties are deliberate. It reads gh auth status and nothing else, because gh reports a credential as invalid without a valid credential: the check does not go blind during the fault it exists to catch. And it never reads, prints or stores a token value — only the type prefix — and never calls gh auth login, logout or refresh, because a repair path that can leave the machine with no credential is the same class of fault as the outage.

Both are also true of the failure path, and preflight works with no workspaces root and a broken config: the thing you reach for when the lab is wrong cannot require the lab to be right.

Mirrors make the clones cheap

facet sync --via-mirror, and every facet spawn, clones from a bare mirror under ~/Projects/.mirrors/ rather than from the forge. Git hardlinks .git/objects when cloning from a local path, so a second workspace over the same repository costs its working tree and zero bytes of objects. Each clone keeps an independent .git, and origin is repointed at the forge, so pushes and fetches reach GitHub.

Hardlinks rather than --shared/alternates: an inode outlives the mirror's directory entry, so repacking or garbage-collecting either side is safe. And correctness never depends on a mirror being fresh — a failed mirror fetch is a warning, because every clone's origin is the forge.

Design

facet knows nothing about your organisation. Which repositories a label implies and what hazards an area carries are data, read from your workspaces root:

File What it holds
.tools/routing.json the repo table, the label → repos prior, and the project board
.knowledge/area-*.md durable hazards, inlined into a spawned workspace

A knowledge fragment holds invariants only — things true about a system whichever issue you happen to be working on. Status, phase and "as of" notes belong in the long-lived workspace named by the fragment's source_workspace. Keeping the two apart is the only thing that stops a fragment quietly becoming a second, staler source of truth. The loader rejects a kind: other than invariants.

facet shells out to git and gh rather than using a pure-Go git library. It needs Git-LFS, credential helpers, SSH-agent auth and — decisively — the --local hardlink clone, none of which go-git provides. And gh already holds working, multi-account authentication.

The manifest format is frozen. facet reproduces one byte for byte, inserting only the empty schema keys a file predates. It never reformats or reorders one, so it can be adopted by an existing, versioned set of workspaces without churn.

Guarantees, and the tests that hold them

  • An existing clone is never touched by sync — no pull, no reset, no clean. It may hold the only copy of unpushed work.
  • --prune deletes only links, never a clone: each entry is confirmed to be a symlink before it is removed, so a plain directory is never mistaken for one.
  • reap counts commits reachable from any local branch and from no remote. Unlike @{u}..HEAD, that also catches a branch which was never pushed at all — the branch most easily lost.
  • reap --reapable deletes only what reap alone would, and checks each workspace again right before deleting it (TestReapReapableChecksAgainBeforeDeleting). It refuses --force.
  • reap never touches the mirror. Deleting a hardlinked object drops that name; the mirror keeps its own.
  • reap also refuses while a tmux pane or process is in the workspace, in any session — not only the one named after it, which a link-windowed pane would slip past. A process counts when its working directory, its executable or any file it has open is inside the workspace, so a watcher started elsewhere that tails a log in it is caught too. Each is named with its pid: clear them by pid, never by a pattern kill, which can take out processes belonging to other workspaces. A macOS system service (an executable under /System) counts only by its working directory: Spotlight indexing the tree, or the virtualization service sharing it with a VM, would otherwise hold every workspace. What runs inside such a VM is not visible from the host. lsof sees only your own processes. tmux list-panes -a and lsof +D are both a convenience layered on the git-based checks: a missing tool degrades to "nothing found", never a false refusal.
  • reap refuses while a loaded launchd job runs from the workspace, running or not: a scheduled job between runs holds nothing open, so lsof misses it, and its next run would fail. A job counts when its Program, an absolute path in its ProgramArguments, or its WorkingDirectory is inside the workspace; only jobs launchctl list shows count, since a plist that is not loaded starts nothing. Unload the job, or move it out, then reap (TestReapReapableLeavesAWorkspaceALaunchdJobRunsFrom).

Status

A personal tool, used daily on one Mac by its author, and held together by a real test suite: CI runs it on macOS and Linux on every change. macOS is the platform it is built for. Windows code paths (junctions, ACLs) remain behind build tags but are no longer tested or supported.

Licence

Apache License 2.0. Copyright 2026 Riccardo Cereghino.

Directories

Path Synopsis
cmd
facet command
Command facet manages task-scoped, manifest-declared workspaces over a set of git repositories, and spawns ephemeral ones from GitHub issues.
Command facet manages task-scoped, manifest-declared workspaces over a set of git repositories, and spawns ephemeral ones from GitHub issues.
internal
claudex
Package claudex launches the Claude Code CLI, the same way ghx/gitx wrap gh and git: facet shells out rather than embedding anything.
Package claudex launches the Claude Code CLI, the same way ghx/gitx wrap gh and git: facet shells out rather than embedding anything.
config
Package config resolves the two roots facet operates between: the workspaces directory, and the projects directory that junction-backed workspaces point into.
Package config resolves the two roots facet operates between: the workspaces directory, and the projects directory that junction-backed workspaces point into.
fslink
Package fslink creates and inspects the filesystem links that back a workspace's `links` entries: directory junctions on Windows, symlinks elsewhere.
Package fslink creates and inspects the filesystem links that back a workspace's `links` entries: directory junctions on Windows, symlinks elsewhere.
ghx
Package ghx wraps the `gh` CLI.
Package ghx wraps the `gh` CLI.
gitx
Package gitx wraps the git CLI.
Package gitx wraps the git CLI.
gitx/gitxtest
Package gitxtest is one configurable fake gitx.Runner, replacing three independent ad hoc fakes (in internal/mirror and internal/workspace) that differed only in which call they made fail.
Package gitxtest is one configurable fake gitx.Runner, replacing three independent ad hoc fakes (in internal/mirror and internal/workspace) that differed only in which call they made fail.
knowledge
Package knowledge loads the durable hazard fragments that get inlined into a spawned workspace's CLAUDE.md.
Package knowledge loads the durable hazard fragments that get inlined into a spawned workspace's CLAUDE.md.
launchd
Package launchd finds the loaded launchd jobs that run from inside a directory, so reap can hold a workspace a background job still needs.
Package launchd finds the loaded launchd jobs that run from inside a directory, so reap can hold a workspace a background job still needs.
lockfile
Package lockfile provides a cross-process advisory lock backed by an O_EXCL lockfile with an mtime heartbeat.
Package lockfile provides a cross-process advisory lock backed by an O_EXCL lockfile with an mtime heartbeat.
manifest
Package manifest reads and writes .workspace.json, the source of truth for a workspace's layout.
Package manifest reads and writes .workspace.json, the source of truth for a workspace's layout.
mirror
Package mirror keeps bare mirrors of remote repositories on local disk, so that workspace clones can be made from a filesystem path instead of the network.
Package mirror keeps bare mirrors of remote repositories on local disk, so that workspace clones can be made from a filesystem path instead of the network.
mux
Package mux answers one question for `facet reap`: is anything still running in a workspace that is about to be deleted?
Package mux answers one question for `facet reap`: is anything still running in a workspace that is about to be deleted?
privacy
Package privacy holds a repository-wide guard, exercised only by its test.
Package privacy holds a repository-wide guard, exercised only by its test.
render
Package render produces the CLAUDE.md that greets whoever -- human or agent -- opens a spawned workspace.
Package render produces the CLAUDE.md that greets whoever -- human or agent -- opens a spawned workspace.
routing
Package routing decides which repositories a GitHub issue needs.
Package routing decides which repositories a GitHub issue needs.
scope
Package scope reads and writes .scope: the issues a workspace covers, one owner/repo#n per line, each newline-terminated.
Package scope reads and writes .scope: the issues a workspace covers, one owner/repo#n per line, each newline-terminated.
wait
Package wait provides the one deadline-bounded poll loop this codebase needed in three different places, written three different ways before this package existed.
Package wait provides the one deadline-bounded poll loop this codebase needed in three different places, written three different ways before this package existed.
workspace
Package workspace implements the operations on a workspace directory: sync, list, create, and the add/remove of links and clones.
Package workspace implements the operations on a workspace directory: sync, list, create, and the add/remove of links and clones.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL