Agile Workflow — Issues, PRs, Autonomous Merge, Releases, Villages
The unified development process for every Tawa repo. If your Claude Code session loads `tawa-docs/.claude/rules/tawa-agile-workflow.md`, it will follow this…
Commandplatform
About
The unified development process for every Tawa repo. If your Claude Code session loads `tawa-docs/.claude/rules/tawa-agile-workflow.md`, it will follow this flow automatically.
Skill Content
This is the raw markdown that gets installed as a Claude Code command.
---
name: tawa-agile-workflow
description: "Tawa issue-first workflow: Forgejo issues, claw/* branches, PRs, tawa gate, self-merge, scheduled merges, labels on the org, release tags, tawa login credentials. Use when opening issues or PRs, merging, tagging releases, or fixing git/npm auth on Forgejo."
---
# Agile Workflow — Issues, PRs, Autonomous Merge, Releases, Villages
The unified development process for every Tawa repo. If your Claude Code session
loads `tawa-docs/.claude/rules/tawa-agile-workflow.md`, it will follow this flow
automatically.
## Ground Rules
- **Git host is Forgejo only** — everything lives at `git.tawa.pro`. No GitHub, no
`mcp__github__*` tools. Git operations go through `mcp__jci-mcp__git_*` or the `git` CLI.
- **Remotes are always HTTPS** (`https://git.insureco.io/org/repo.git`). Never switch to
SSH to fix auth — run `tawa login`, see [Auth failures](#auth-failures--run-tawa-login).
- **`main` is PR-only.** Never commit to `main`; it advances solely through a merged PR —
one the **agent merges itself** (see Autonomous Merge below).
## Issue-Driven Development (required)
Every feature, bug fix, or non-trivial task **must have a git issue** before code is written.
```
Create issue → branch → implement → PR → self-merge → close via commit message
```
1. Check for an existing issue first (`git_issue_list`); create one if missing (`git_issue_create`).
2. Reference the issue number in the commit: `feat: add tagline to branding (#42)`.
3. Auto-close from the commit body with `fix #N`, `close #N`, or `resolve #N`.
Only truly trivial one-liners are exempt.
## The Feature Loop
1. **Create issue first** — `git_issue_create`
2. **Plan** — `planner` agent breaks down the work
3. **TDD** — `tdd-guide` agent, tests written first (RED → GREEN → refactor, 80%+ coverage)
4. **Branch** — in your own worktree off `origin/main`: `claw/<task>-<shortid>`
5. **Code review** — `code-reviewer` agent after writing code
6. **Commit & push** — explicit paths, reference the issue (`feat: add X (#N)`)
7. **Open PR** — `git_pr_create`
8. **Rebase & verify green** — `git fetch origin && git rebase origin/main`, then run
**`tawa gate`** (the repo's `gate` script, else typecheck / lint / test / build; see
[The Merge Gate](gate.md)). This is the gate that replaces human review, and CI runs the same
command as a required check.
9. **Self-merge** — `git_pr_merge` / `tawa-pr merge`. Automatic; do not wait for a human (see below).
If the required `gate` check is still running, the merge is **scheduled**, not refused:
Forgejo merges it when the check passes. Move on; do not poll.
10. **Cut release** — `git_release_create` after a deploy-worthy batch
## Autonomous Merge — Agents Self-Merge Their PRs
**Every agent runs the full pipeline end-to-end and merges its own PR. The merge is the
default terminal step, not a handoff.** The human ("vibe coder") does not review or click
merge — they tell the agent to *test before merging*, and a green, rebased PR merges
itself. Agents are pulled in **only on a major error**.
**Do NOT wait for the human:**
- Never end a turn at "PR is open, ready for you to merge." A PR you opened is yours to merge.
- Never ask "want me to merge this?" for a routine change — merging is the assumed intent.
- When agents fan out, the orchestrator **serializes** merges (one PR at a time, each
rebased on the prior merge) and **merges them itself** — nothing is parked for a person.
**Escalate instead of merging — STOP and surface to the human ONLY when:**
- A **merge/rebase conflict** you cannot cleanly and confidently resolve.
- **Typecheck / lint / tests / build fail** and you can't green them.
- A **deploy-gate or smoke-test failure**, or a red post-merge signal.
- The change is **destructive, irreversible, or outside the task's stated scope** (schema
drops, data migrations, mass deletions, secret rotation, force-push to a protected branch).
- A **security-sensitive** change you're not confident is correct.
- Genuinely **ambiguous requirements** where the wrong guess is expensive.
**Merge when the gate passes (2026-10-24).** Run `tawa gate` locally, open the PR, then merge
with `git_pr_merge` (jci-mcp) or `tawa-pr merge` (cloud sessions). The required
`gate / gate (pull_request)` check takes about 5-10 minutes, and merging before it finishes
used to return a 405 that agents retried in a loop. Now, when the head commit's checks are
still pending, the call schedules the merge with Forgejo's auto-merge
(`merge_when_checks_succeed`) and returns success:
- `tawa-pr merge` prints that the merge is scheduled and exits 0. Pass `--now` for the old
one-shot behaviour.
- jci-mcp's `git_pr_merge` gets the same behaviour (a parallel PR in jci-mcp) and returns
`scheduled: true`.
- **The agent moves on and does not poll.** Forgejo does the merge.
- A **failing** gate leaves the PR open; the call exits non-zero (or returns the failing check)
naming it. That is a red signal to fix, not to retry: push a fix and merge again.
- **Two required checks, and each says why (forgejo-custom#22).** `gate` runs `tawa gate`;
`dod` runs the Definition-of-Done check on the PR body and **re-runs when the body is edited**,
in seconds, without re-running the gate. Each posts a non-required `gate / why` / `dod / why`
status whose description is the reason in one line (failed step + first error, or the missing
DoD sections). `git_pr_get` returns it as `checks[].reason` with a `next` step; read it instead
of guessing. A DoD failure is fixed by editing the PR body, not by pushing.
- A conflict or a branch behind `main` is still refused with a clear error; rebase first.
"I'm slightly unsure the feature is perfect" is **not** a major error — that's what the
issue, the diff, and the next iteration are for. Outside the list above, proceed to merge.
**Permissions & enforcement (already in place):**
- Claude Code's global settings allow `Bash(*)` and the Forgejo PR tools (`git_pr_create`,
`git_pr_merge`, `git_pr_get`, `git_pr_list`) with no prompt.
- Branch protection on `main` (`required_approvals=0`) enforces PR-only mechanically while
still letting the agent self-merge — that is exactly why approvals are 0.
- Release tags are protected too: only the accounts on a repository's tag rule can create,
move or delete a tag matching `v*` or `*-v*`. See [Release Management](#release-management).
- Both are applied by the `tawa` CLI (**0.27.0+**). `tawa git create` and `tawa sample --git`
protect `main` and release tags on the repository they create, with no further step. For a
repository that already exists, run `tawa git protect <owner/repo>` — a **dry run** that
prints what would change — then add `--apply`. `tawa git protect --all` sweeps every
repository in the org (`--org <name>`, default `insureco`); `--all --apply` prints how many
repositories need changes and asks first (`--yes` skips the question). `--main` or `--tags`
limits it to one kind of rule.
> **Correction (2026-09-29):** this section used to name `forgejo-protect-main` as what
> enforces PR-only `main`. No such command exists in the `tawa` CLI, so anyone who went
> looking for it found nothing and may have left a repository unprotected. Use
> `tawa git protect` (tawa 0.27.0+) instead. Forgejo 14 has tag protection per repository
> only, with no org-wide setting, which is why the CLI applies it repository by repository.
**Repo hygiene on deploy (iec-builder#334).** The builder brings each service repo up to this
standard itself, the next time the service deploys, so there is no manual rollout. It is
controlled by the runtime setting `repoHygiene.mode` (`off` | `report` | `apply`, default
`report`; Console → Operations → Builder Switches) and `repoHygiene.excludeRepos`. Every step is
**additive**: it never loosens or removes an existing rule, and it never pushes to `main`.
| Step | Does (in `apply`) |
|---|---|
| Protection | Creates a PR-only rule on `main`/`master` when none exists (`enable_push=false`, `required_approvals=0`, `block_on_outdated_branch=true`). On an existing rule it adds only what is missing, closes direct push unless it is a push whitelist, and logs a stricter or different setting without touching it |
| Gate workflows | When `.forgejo/workflows/gate.yml` or `dod.yml` is not on the default branch (Node repos only: a root `package.json`), opens one PR from `claw/repo-hygiene-gate` adding whichever of forgejo-custom's `ci/gate.yml` / `ci/dod.yml` is missing (#22), with a `DoD-exempt:` line. Never two at once. Merging it is a push to the default branch, so an ungated service redeploys |
| Required checks | Adds `gate / gate (pull_request)`, and `dod / dod (pull_request)` once dod.yml is on the default branch, to the rule's required contexts only when gate.yml is on the default branch **and** its most recent conclusive **gate.yml** run is green (other workflows' runs are ignored). Never while red, running or absent: that would wedge the repo |
In `report` mode it performs the reads and logs what it would change, and writes nothing. Each
step writes one `[repo-hygiene]` build-log line and, when it has something to do, a Septor event
`repo.hygiene.protection`, `.gate_pr` or `.required_check`. It runs alongside the deploy
(fire-and-forget, 25 s cap, fail-open), and a nightly sweep at 04:00 UTC applies the same
steps to services not deployed in 7 days. See [Build & Deploy Pipeline](build-pipeline.md), step 24b.
**Deploy follows the merge (iec-builder#290).** An ungated service deploys to prod when its PR
merges, through the signed Forgejo org webhook (`autoDeploy.onMerge`, on since 2026-10-15). A gated service
deploys when its commit is approved. Running `tawa deploy --prod` yourself is still fine, and it
attaches to the automatic build instead of racing it. See [Ship on Approval and on Merge](auto-deploy.md).
## Labels — the board's source of truth
**Type labels:** `feature`, `bug`, `ux`, `infra`, `debt`, `phase`
**Status labels → Kanban columns** (moving a card = swap the `status:*` label):
| Label | Column | Color |
|-------|--------|-------|
| `status:backlog` | Backlog | `#64748b` |
| `status:in-progress` | In Progress | `#2563eb` |
| `status:review` | In Review | `#d97706` |
| `status:blocked` | Blocked | `#dc2626` |
| (closed, no label) | Done | automatic |
### Labels live on the org, not on each repo
Forgejo labels are per-repo, and nothing creates them when a repo is made — so until
2026-09-18 most repos had none, and the first labelled issue on any of them failed with
`Label "feature" does not exist in <repo>. Labels there: (none)`. Agents then hand-built a
label set one repo at a time, with drifting colors.
The ten labels above now exist **once, on the `insureco` org**, and jci-mcp resolves org
labels alongside a repo's own ([jci-mcp#126](https://git.insureco.io/insureco/jci-mcp/issues/126)).
Every `insureco` repo — including one created five minutes ago — accepts them with zero
labels of its own. There is nothing to bootstrap.
```
git_label { action: "list", org: "insureco" } # the shared taxonomy
git_label { action: "create", org: "insureco", name, color } # add to it — every repo gets it
git_label { action: "create", repo: "insureco/my-svc", name, color } # one repo only
git_issue_labels_list { repo } # what an issue here can carry; each label marked scope: org | repo
```
- **A missing standard label is an org problem.** Add it to the org, never to the repo.
- **Repo-level labels are for something genuinely specific to one repo.** A repo label
**shadows** an org label of the same name, so a repo-level `bug` with its own color
silently replaces the shared one there.
- **An unknown name still fails loudly**, on issues *and* PRs, listing both the repo's and
the org's labels. That is deliberate: the old behaviour dropped unknown labels and
reported success, leaving issues with no labels at all.
- A few repos (`jci-mcp`, `bio-vault`, `iec-insurebio`) still carry repo-level copies that
predate this. They are harmless. Do not delete them casually — deleting a label strips it
from every issue that carries it.
## Sprint Rhythm
1. **Plan** — review open issues, pick the sprint's work, label with milestone
2. **Build** — one issue per branch/feature, commit often
3. **Ship** — the agent **self-merges its own PR** (rebase → verify green → `git_pr_merge`),
cuts a release, closes issues. No human merge gate.
4. **Retrospect** — which issues stayed open, and why?
### Commit message format
```
<type>: <description> (#N)
```
Types: `feat, fix, refactor, docs, test, chore, perf, ci`. Always link the issue when one
exists. Attribution is disabled globally.
## Release Management
Cut a release after every meaningful, deployed batch. Check existing releases first
(`git_release_list`), then `git_release_create`.
| Bump | Meaning |
|------|---------|
| Patch `v1.0.x` | Bug fixes, minor tweaks |
| Minor `v1.x.0` | New features, UI additions |
| Major `vX.0.0` | Breaking changes, rewrites |
### Who can create a release tag
Every repository created with `tawa git create` or `tawa sample --git` (tawa **0.27.0+**), and
every repository `tawa git protect --apply` has been run on, carries tag rules for `v*` and
`*-v*`. Only the accounts on the rule's allow-list can create, move or delete a matching tag.
Forgejo has **no admin bypass**: a site or org admin who is not on the list is refused like
anyone else.
| | Default allow-list |
|--|--|
| Org-owned repository | the person who ran the command, plus the org's `Owners` team, plus its `runners` team when the org has one |
| Personal repository | the person who ran the command |
`iec-admin` is on the list only when it was the account that ran the command; it is never
added to a repository where it is only the builder's read collaborator. Each run prints who
is allowed. `--allow-user`, `--allow-team` and `--pattern` (all repeatable), or
`release_tags` in `~/.tawa/config.yaml`, replace the defaults.
Patterns are Forgejo globs matched against the **whole** tag name, and `*` matches any
characters. `v*` matches `v1.2.3` and also any other tag that starts with `v`, such as
`vendor-thing`; `*-v*` matches `agent-v0.7.0` and any tag containing `-v`. A tag you did not
mean as a release can therefore be protected too.
#### When a tag push or `git_release_create` is refused
The repository's tag rule does not include the account you are using. Do not work around it
(a different account, a tag name chosen to dodge the pattern, deleting the rule). Check the
rule instead:
```bash
tawa git protect <owner/repo> --tags # dry run: prints the current rule and who it allows
```
A rule whose allow-list is not the default is reported as `DIFFERS` and left alone; the line
says when it leaves you out. If you should be on it, ask an owner of the repository to add
you (`--allow-user`, then `--apply --update`). Changing someone else's rule to include
yourself is an owner's decision, not a workaround.
`tawa git protect` refuses to write a rule that would leave the person running it unable to
create matching tags, unless `--lock-me-out` is passed. If your git username is not known,
it makes no rule at all; run `tawa login`.
## Documentation & Decisions
Use the **wiki** to capture the *why* — architecture decisions, non-obvious "why X instead
of Y" choices, onboarding context (data model, auth flow, deploy process). Tools:
`git_wiki_create` / `git_wiki_update`. Write a wiki page when a new pattern is introduced or
a non-obvious decision is made; update it when behavior changes.
## Villages — Cross-Repo System Tracking
The ecosystem is organized into **Villages** — high-level system components spanning multiple
repos. All 15 Villages reaching v1 constitutes **Voyager** (Ecosystem Release 1).
- Issues live in the repo where the code lives; a **Forgejo org-level Project** (one per
Village) is the cross-repo board.
- Each constituent repo tracks its own `v1` milestone (`git_milestone_create`).
- Each Village gets a lightweight `{village}-wiki` repo (`has_issues: false`) for roadmap + ADRs.
- When all repos in a Village hit v1 → cut Village v1 release → Voyager milestone advances.
| Layer | Tool |
|-------|------|
| Village roadmap & ADRs | Wiki on `{village}-wiki` repo |
| Village v1 target | `v1` milestone per repo |
| Cross-repo board | Forgejo org Project (one per Village) |
| Ecosystem release | `git_release_create` on the `voyager` tracking repo |
## Auth failures — run `tawa login`
`tawa login` is how a machine gets its Forgejo credential. One call authenticates, mints a
PAT, and stores it for the `tawa` CLI (`~/.tawa/forgejo-credentials.json`), for **git**
(the OS credential helper) and, from tawa 0.36.0, for **npm/pnpm** (`~/.npmrc`). With saved
credentials present it runs non-interactively.
```bash
tawa login --save
git ls-remote origin HEAD # verify, without touching the credential store
```
There is nothing to do afterwards. Do **not** hand-mint a PAT and store it yourself.
> **Superseded (2026-09-20).** This page used to say "do NOT reflexively re-login", and told
> you to mint a stable `git-cli-*` PAT through the Forgejo admin CLI and store it by hand so
> it would sit outside the `tawa-cli-` cull. **That guidance is stale. Do not follow it.**
> It read as a prohibition rather than a caveat: an agent avoided `tawa login`, worked around
> it, and then minted a redundant token nobody needed.
>
> What is actually true, verified against `iec-builder/src/routes/users.ts` on 2026-09-22:
> `deleteStaleTokens(username, machineId)` deletes only **this machine's** tokens, those named
> `tawa-cli-<machineId>-*`, and deletes nothing at all when the caller sends no machineId. A
> login on one machine never revokes another machine's token, so a laptop, a server and a
> cloud-runner session can all stay logged in as the same user at once. `tawa login` also
> rewrites the git credential in the same call, so this machine ends up holding a working
> credential. The separate stable PAT solved a problem that never existed.
**Scopes.** The token `tawa login` mints on a laptop carries `write:repository`, `write:issue`,
`write:organization`, `write:user` and `read:package`. That covers git, the Forgejo `/pulls` API,
filing and commenting on issues, attaching files to issue and PR comments, and installing private
`@insureco/*` packages. `write:issue` was added in iec-builder#375 (1 Nov 2026): a token minted
before that cannot create issues or upload attachments (403), so run `tawa login` again. A
cloud-runner session or Chaac task token is narrower: exactly
`read:repository write:repository write:issue read:package read:user read:organization`, so `tawa-pr issue` /
`chaac-pr issue` file, comment on and close issues as you, `tawa-pr whoami` can name you, and it
can never add an SSH key or change an org (iec-builder#168).
**npm and pnpm.** tawa **0.36.0+** writes the same token to `~/.npmrc`:
```ini
@insureco:registry=https://git.insureco.io/api/packages/insureco/npm/
//git.insureco.io/api/packages/insureco/npm/:_authToken=<the token>
```
so `pnpm install` / `npm install` of `@insureco/*` works right after a login, on a laptop or in
an agent worktree. A `401` from that registry means the token predates `read:package` (minted
before 2026-10-15, iec-builder#292) or the CLI predates 0.36.0 (tawa-cli#173): upgrade `tawa`
and run `tawa login` again. Do **not** hand-make an npm token for the registry. A project's own
`.npmrc` only needs the `@insureco:registry=` line; the auth comes from `~/.npmrc`.
⚠️ Never test a token by putting it in a git URL (`https://user:$TOK@host/…`) — the
credential helper silently overwrites the stored credential with whatever the URL carried.
## Commits Are the Only Durable Save
Uncommitted edits live only in the working tree — a branch switch, rebase, or another
agent's operation can discard them with no recovery. **Commit as soon as a change is
coherent**, to your `claw/<task>-<shortid>` branch (never `main`), staging **explicit paths**
(`git add <paths>` — never `git add -u`/`-a`, which sweep up other agents' uncommitted edits
on a shared checkout). Small WIP commits are fine — they squash at merge; lost work cannot.
> There is **no** "Stop hook auto-commits `git add -u` and pushes to `main`" safety net —
> that older behavior is removed and superseded. Any automated commit must be branch-aware:
> refuse on `main`, stage explicit paths, and go through a self-merged PR.
## The One-Liner
> No work without an issue → plan → tests first → branch → commit referencing `#N` → PR →
> rebase + verify green → **agent self-merges** → cut a release per batch. Human is pulled
> in only on a major error. Issues live with the code; Villages aggregate cross-repo; Wikis
> hold the "why."
## Common Mistakes
- Starting work with no issue (only trivial one-liners are exempt).
- Ending at "PR is open, ready for you to merge" — a PR you opened is yours to self-merge.
- Asking "should I merge?" for a routine, green, rebased PR — merging is the assumed intent.
- Committing to `main` directly, or using `git add -u`/`-a` on a shared checkout.
- Merging without running the repo's tests first — the test pass is what replaces review.
- Committing without a `#N` reference when an issue exists.
- Creating `feature` / `status:*` labels on a repo because an issue create said they were
missing — they live on the org. See [Labels live on the org](#labels-live-on-the-org-not-on-each-repo).
- Switching a remote to SSH to dodge an auth failure.
- Looking for `forgejo-protect-main` — it does not exist. Use `tawa git protect` (0.27.0+).
- Running `tawa git protect --all --apply` without first reading the dry run.
- Working around a refused release tag instead of checking the rule with a dry run. There is
no admin bypass; only the accounts on the allow-list can tag.
- Trusting the sweep summary's "unchanged" count: it currently counts a repository with a
`DIFFERS` rule as unchanged ([tawa-cli#128](https://git.insureco.io/insureco/tawa-cli/issues/128)).
Read the per-repository `DIFFERS` lines.
- Hand-minting a Forgejo PAT or an npm token, or avoiding `tawa login` when a push or a
`pnpm install` of `@insureco/*` 401s — `tawa login` (0.36.0+) is the supported fix and
rewrites the git credential and `~/.npmrc` itself. See above.
- Using GitHub / `mcp__github__*` tools — everything is Forgejo at `git.tawa.pro`.
- Tracking cross-repo work as issues in a "meta" repo — issues live where the code lives;
aggregate them with a Village Project instead.
Install
Copy the skill content and save it to:
~/.claude/commands/tawa-agile-workflow.mdComing soon via CLI:
tawa chaac install tawa-agile-workflowDetails
- Format
- Command
- Category
- platform
- Version
- 1.0.849
- Tokens
- ~5,679
- Updated
- 2026-11-25
platformagilegitforgejoissuespull-requestsmergereleasesvillagesprocess