From 8891fa17eae33917eb45dcbc042ba1f26fb7a523 Mon Sep 17 00:00:00 2001 From: Glucksberg Date: Fri, 30 Jan 2026 00:23:21 +0000 Subject: [PATCH] feat(skills): add fork-manager skill for managing forks with open PRs New skill to help manage forks where you contribute PRs but also use improvements before they're merged upstream. Features: - Track open PRs and their branch status - Sync main with upstream - Rebase PR branches on upstream/main - Build production branch with all pending PRs merged - Generate status reports Useful for maintaining forks of actively developed projects. --- skills/fork-manager/SKILL.md | 229 +++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 skills/fork-manager/SKILL.md diff --git a/skills/fork-manager/SKILL.md b/skills/fork-manager/SKILL.md new file mode 100644 index 000000000..d787d2d86 --- /dev/null +++ b/skills/fork-manager/SKILL.md @@ -0,0 +1,229 @@ +--- +name: fork-manager +description: Manage forks with open PRs - sync upstream, rebase branches, track PR status, and maintain production branches with pending contributions. +metadata: {"moltbot":{"emoji":"🍴","os":["darwin","linux"],"requires":{"bins":["git","gh"]}}} +--- + +# Fork Manager Skill + +Skill para gerenciar forks de repositórios onde você contribui com PRs mas também usa as melhorias antes de serem mergeadas no upstream. + +## Quando usar + +- Usuário pede para atualizar/sincronizar um fork +- Usuário quer saber status dos PRs abertos +- Usuário quer fazer rebase das branches de PR +- Usuário quer criar uma branch de produção com todos os PRs + +## Configuração + +Configs ficam em `~/.clawdbot/fork-manager/.json`: + +```json +{ + "repo": "owner/repo", + "fork": "your-user/repo", + "localPath": "/path/to/local/clone", + "mainBranch": "main", + "productionBranch": "main-with-all-prs", + "upstreamRemote": "upstream", + "originRemote": "origin", + "openPRs": [123, 456], + "prBranches": { + "123": "fix/issue-123", + "456": "feat/feature-456" + }, + "lastSync": "2026-01-28T12:00:00Z" +} +``` + +## Fluxo de Análise + +### 1. Carregar config + +```bash +CONFIG_DIR=~/.clawdbot/fork-manager +cat "$CONFIG_DIR/.json" +``` + +### 2. Navegar para o repositório + +```bash +cd +``` + +### 3. Fetch de ambos remotes + +```bash +git fetch +git fetch +``` + +### 4. Analisar estado do main + +```bash +# Commits que upstream tem e origin/main não tem +git log --oneline /../ + +# Contar commits atrás +git rev-list --count /../ +``` + +### 5. Verificar PRs abertos via GitHub CLI + +```bash +# Listar PRs abertos do usuário +gh pr list --state open --author @me --json number,title,headRefName,state + +# Verificar status de um PR específico +gh pr view --json state,mergedAt,closedAt,title +``` + +### 6. Classificar cada PR + +Para cada PR no config, verificar: + +| Estado | Condição | Ação | +|--------|----------|------| +| **open** | PR aberto no GitHub | Manter, verificar se precisa rebase | +| **merged** | PR foi mergeado | Remover do config, deletar branch local | +| **closed** | PR fechado sem merge | Verificar motivo, possivelmente remover | +| **conflict** | Branch tem conflitos com upstream | Precisa rebase manual | +| **outdated** | Branch está atrás do upstream | Precisa rebase | + +Comando para verificar se branch precisa rebase: +```bash +git log --oneline /../ | wc -l # commits à frente +git log --oneline /../ | wc -l # commits atrás +``` + +## Comandos do Agente + +### `status` - Verificar estado atual + +1. Carregar config +2. Fetch remotes +3. Contar commits atrás do upstream +4. Listar PRs e seus estados +5. Reportar ao usuário + +### `sync` - Sincronizar main com upstream + +```bash +cd +git fetch +git checkout +git merge / +git push +``` + +### `rebase ` - Rebase de uma branch específica + +```bash +git checkout +git fetch +git rebase / +# Se conflito: resolver e git rebase --continue +git push --force-with-lease +``` + +### `rebase-all` - Rebase de todas as branches de PR + +Para cada branch em `prBranches`: +1. Checkout da branch +2. Rebase no upstream/main +3. Push com --force-with-lease +4. Reportar sucesso/falha + +### `update-config` - Atualizar config com PRs atuais + +```bash +# Buscar PRs abertos +gh pr list --state open --author @me --repo --json number,headRefName + +# Atualizar o arquivo JSON com os PRs atuais +``` + +### `build-production` - Criar branch de produção com todos os PRs + +```bash +cd +git fetch +git fetch + +# Deletar branch antiga se existir +git branch -D 2>/dev/null || true + +# Criar nova branch a partir do upstream +git checkout -b / + +# Mergear cada PR branch +for branch in ; do + git merge /$branch -m "Merge PR #: " + # Se conflito, resolver +done + +# Push +git push <originRemote> <productionBranch> --force + +# Build +bun run build +``` + +### `full-sync` - Sincronização completa + +1. `sync` - Atualizar main +2. `update-config` - Atualizar lista de PRs +3. `rebase-all` - Rebase de todas as branches +4. `build-production` - Recriar branch de produção +5. `bun run build` - Rebuild + +## Relatório para o Usuário + +Após qualquer operação, gerar relatório: + +```markdown +## 🍴 Fork Status: <repo> + +### Upstream Sync +- **Main branch:** X commits behind upstream +- **Last sync:** <date> + +### Open PRs (Y total) + +| # | Branch | Status | Action Needed | +|---|--------|--------|---------------| +| 123 | fix/issue-123 | ✅ Up to date | None | +| 456 | feat/feature | ⚠️ Needs rebase | Run rebase | +| 789 | fix/bug | ❌ Has conflicts | Manual resolution | + +### Production Branch +- **Branch:** main-with-all-prs +- **Contains:** PRs #123, #456, #789 +- **Status:** ✅ Up to date / ⚠️ Needs rebuild + +### Recommended Actions +1. ... +2. ... +``` + +## Notas Importantes + +- Sempre usar `--force-with-lease` em vez de `--force` para push +- Sempre fazer backup antes de operações destrutivas +- Usar `bun run` em vez de `npm run` +- Verificar se há trabalho não commitado antes de operações git +- Manter o config atualizado após cada operação + +## Exemplo de Uso + +Usuário: "atualiza meu fork do claude-mem" + +Agente: +1. Lê config de `~/.clawdbot/fork-manager/claude-mem.json` +2. Executa `status` para entender situação atual +3. Se main está atrás, executa `sync` +4. Se PRs precisam rebase, executa `rebase-all` +5. Atualiza `productionBranch` se necessário +6. Executa `bun run build` +7. Reporta resultado ao usuário