Skip to content

Commit 80d5594

Browse files
authored
Merge pull request #67 from Contentrain/docs/remote-branch-cleanup-and-prune
docs: document contentrain prune + remote cr/* branch cleanup
2 parents 532ed56 + f89495a commit 80d5594

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

docs/concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ cr/normalize/extract/... ← normalize extraction
184184
cr/normalize/reuse/... ← source patching
185185
```
186186

187-
Branches are auto-merged or held for review depending on your workflow config.
187+
Branches are auto-merged or held for review depending on your workflow config. When a review branch is merged or rejected, its remote copy is deleted too, so merged branches don't linger as phantom pending reviews — run `contentrain prune` to drain any existing backlog, or set `remoteBranchCleanup: false` to opt out.
188188

189189
## How It Compares
190190

docs/packages/cli.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ Example: `contentrain --debug status` or `CONTENTRAIN_DEBUG=1 contentrain status
6060
|---------|--------|
6161
| `contentrain init` | Initialize `.contentrain/`, git workflow, templates, and IDE rules |
6262
| `contentrain status` | Show project overview, models, branch pressure, and validation summary |
63-
| `contentrain doctor` | Check setup health, SDK freshness, orphan content, and branch limits |
63+
| `contentrain doctor` | Check setup health, SDK freshness, orphan content, local branch limits, and remote `cr/*` count |
6464
| `contentrain validate` | Validate content against schemas, optionally create review-branch fixes |
6565
| `contentrain generate` | Generate `.contentrain/client/` and `#contentrain` package imports |
6666
| `contentrain describe` | Display full model schema and sample data |
6767
| `contentrain describe-format` | Show file format specification and storage conventions |
6868
| `contentrain scaffold` | Apply starter templates (blog, landing, docs, SaaS, ...) |
69-
| `contentrain diff` | Review and merge or reject pending `cr/*` branches interactively |
70-
| `contentrain merge <branch>` | Merge one pending `cr/*` branch non-interactively |
69+
| `contentrain diff` | Review and merge or reject pending `cr/*` branches interactively (deletes the remote copy on merge/reject) |
70+
| `contentrain merge <branch>` | Merge one pending `cr/*` branch non-interactively (deletes the remote copy) |
71+
| `contentrain prune` | Delete merged `cr/*` branches locally and on the remote (drain the backlog) |
7172
| `contentrain setup` | Configure MCP server and AI rules for your IDE |
7273
| `contentrain skills` | Install, update, or list AI skills and rules for your IDE |
7374
| `contentrain serve` | Start the local review UI, the MCP stdio server, or the MCP HTTP server |
@@ -238,7 +239,20 @@ contentrain merge cr/content/faq/1234-abcd
238239
contentrain merge cr/content/faq/1234-abcd --yes # Skip confirm (CI)
239240
```
240241

241-
Non-interactive single-branch sibling of `contentrain diff`. Delegates to MCP's `mergeBranch` so dirty-file protections + selective sync warnings behave identically.
242+
Non-interactive single-branch sibling of `contentrain diff`. Delegates to MCP's `mergeBranch` so dirty-file protections + selective sync warnings behave identically. After a successful merge it also deletes the branch's copy on the remote — best-effort, so an offline or permission failure only prints a warning. Opt out with `remoteBranchCleanup: false` in `config.json`.
243+
244+
---
245+
246+
### `contentrain prune`
247+
248+
```bash
249+
contentrain prune --dry-run # Preview merged cr/* branches (local + remote)
250+
contentrain prune # Confirm, then delete them
251+
contentrain prune --yes # Skip confirm (CI)
252+
contentrain prune --json # Machine-readable output (mutates only with --yes)
253+
```
254+
255+
Drains already-merged `cr/*` branches: local ones past their retention period plus every merged copy left on the remote. This is the operator-facing cleanup for backlogs the per-merge deletion could not remove — e.g. branches merged before remote cleanup shipped, or after an offline/permission failure. Merged detection uses the same ancestry + patch-id classification as the rest of the toolchain, so branches orphaned by a base-history rewrite are still recognised. Governed by `remoteBranchCleanup` in `config.json`; exits non-zero if any remote deletion fails.
242256

243257
---
244258

docs/packages/mcp.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The MCP server exposes **19 tools** organized by function. Each tool includes [M
7676
| `contentrain_status` | Project overview | Config, models, branch health, context, validation summary |
7777
| `contentrain_describe` | Model deep-dive | Full schema, sample data, field types for any model |
7878
| `contentrain_describe_format` | Format reference | File structure, JSON formats, markdown conventions, locale strategies |
79-
| `contentrain_doctor` | Health diagnostics | Setup validation, SDK freshness, orphan content, branch limits, unused keys, missing translations |
79+
| `contentrain_doctor` | Health diagnostics | Setup validation, SDK freshness, orphan content, local branch limits, remote `cr/*` count, unused keys, missing translations |
8080
| `contentrain_content_list` | Read content | List and filter content entries with optional relation resolution |
8181

8282
### Write Tools (Git-Backed, Branch-Isolated)
@@ -90,10 +90,10 @@ The MCP server exposes **19 tools** organized by function. Each tool includes [M
9090
| `contentrain_content_save` | Write content | Save entries for any model kind (collection, singleton, dictionary, document) |
9191
| `contentrain_content_delete` | Remove content | Delete specific content entries |
9292
| `contentrain_validate` | Check & fix | Validate content against schemas, optionally auto-fix structural issues |
93-
| `contentrain_submit` | Push branches | Push `cr/*` review branches to remote |
94-
| `contentrain_merge` | Merge branches | Merge a review-mode branch into contentrain locally (by exact branch or model; no external platform needed) |
95-
| `contentrain_branch_list` | Inspect branches | List pending `cr/*` branches with merge status and branch-health pressure |
96-
| `contentrain_branch_delete` | Clean up branches | Delete a stale/failed `cr/*` branch (the contentrain branch is protected) |
93+
| `contentrain_submit` | Push branches | Push `cr/*` review branches to remote, then lazily prune merged local + remote leftovers |
94+
| `contentrain_merge` | Merge branches | Merge a review-mode branch into contentrain locally (by exact branch or model; no external platform needed); deletes the branch's remote copy |
95+
| `contentrain_branch_list` | Inspect branches | List pending `cr/*` branches with merge status and branch-health pressure (`remote: true` adds a remote view + remote-only leftovers) |
96+
| `contentrain_branch_delete` | Clean up branches | Delete a stale/failed `cr/*` branch locally and on the remote (the contentrain branch is protected; supports remote-only deletion) |
9797

9898
### Normalize Tools (Scan + Apply)
9999

@@ -133,7 +133,9 @@ All write operations create or update `cr/*` branches:
133133
- Content changes go to isolated branches (`cr/{scope}/{target}[/{locale}]/{timestamp}-{suffix}`)
134134
- Humans review via `contentrain diff` or the serve UI
135135
- Approved changes merge into the `contentrain` branch, baseBranch is advanced via update-ref
136-
- Branch health is tracked and surfaced via `contentrain_status` (warning at 50, blocked at 80 active branches)
136+
- Merging (or deleting) a branch also removes its copy on the remote, so merged branches don't pile up as phantom pending reviews — best-effort, opt out with `remoteBranchCleanup: false` in `config.json`. Drain an existing backlog with `contentrain prune`
137+
- Merged-branch detection survives base-history rewrites (ancestry check with a patch-id fallback)
138+
- Branch health is tracked and surfaced via `contentrain_status` (warning at 50, blocked at 80 active branches); `contentrain_doctor` adds a remote `cr/*` count
137139
- Legacy `contentrain/*` branches are auto-migrated on first init
138140

139141
### 4. Local-First by Default, Remote Providers Opt-In

0 commit comments

Comments
 (0)