feed-badger
The reverse of welcome-ai-badger: it finds framework-managed content you have added or
changed in a project, keeps only what is genuinely reusable, generalizes it, and contributes it
back to ai-badger as a draft PR for human review.
Responsibility split
- Scripts (mechanical):
detect_additions.py diffs .ai-badger/ against manifest.json
and lists candidates; open_pr.py does the git branch/commit/push + gh pr create --draft.
- You (creative): classify each candidate (agnostic / generalizable / project-specific),
drop project-specific ones with a reason, generalize the keepers (strip project paths,
domain terms, repo names), and place each into the correct
{stack}/{feature}/ path in an
ai-badger checkout.
Flow
Detect candidates (from the target repo root):
python3 "$AI_BADGER/features/common/skills/feed-badger/scripts/detect_additions.py" --target . --root "$AI_BADGER"
Emits new (files not from the framework) and changed (files edited beyond the scaffold)
candidates, by feature.
Classify & generalize. For each candidate decide agnostic / generalizable /
project-specific. Drop project-specific ones (state why). For the keepers, rewrite to remove
anything project-coupled — no repo names, no domain nouns, no absolute paths. Decide the
target stack (or common) and feature. A brand-new stack or feature is allowed.
Place into an ai-badger checkout. Clone or reuse a checkout of Arasz/ai-badger, write
each generalized file to its {stack}/{feature}/ path, then regenerate the index:
python3 "<checkout>/tooling/index_build.py"
python3 "<checkout>/tooling/validate.py" --all
Open a draft PR. Write a PR body summarizing each contribution and why it is agnostic,
then:
python3 "$AI_BADGER/features/common/skills/feed-badger/scripts/open_pr.py" \
--checkout <checkout> --branch feed/<slug> \
--title "feed: <summary>" --body-file <body.md> --repo Arasz/ai-badger \
--path features/<stack>/<feature>/<name> --path index.json
--path is required and repeatable: name every path you placed, plus index.json if
you regenerated it. Only declared paths are staged, so an unrelated dirty file in the
checkout cannot ride along in the PR.
Every declared path is scanned for credential-shaped literals before anything is staged.
A finding refuses the PR and names the file and the shape — never the matched text. It is
a guard, not proof: it checks known literal shapes, so a clean run is not a certificate.
Use --dry-run to preview the git/gh commands without executing (useful for testing).
Rules
- Draft, always. Contributions land as draft PRs; a human reviews and merges. Never
auto-merge.
- Agnostic bar is high. When unsure whether something is reusable, keep it in the project,
not the framework. Better to under-contribute than to pollute the catalog.
- Provenance drives detection.
feed-badger only works on repos scaffolded by ai-badger
(those with .ai-badger/manifest.json).
Gotchas
- Draft PR, always. A human reviews and merges; never auto-merge.
--path is required and repeatable. Only declared paths are staged, so an unrelated dirty
file cannot ride along in the PR.
- The credential scan is a guard, not proof. It checks known literal shapes; a clean run is
not a certificate.
- The agnostic bar is high. When unsure, keep it in the project, not the framework.
Error Recovery
When any script in the feed flow (detect_additions.py, open_pr.py) exits
non-zero or emits an error, attempt recovery before surfacing the failure.
Parse the error. Scripts emit structured JSON — read the error field to
classify the failure.
Attempt automatic recovery. Try the applicable fix, then re-run the
failed step.
| Error |
Fix |
manifest.json missing or corrupt |
Project not scaffolded — run welcome-ai-badger first |
detect_additions.py found no candidates |
Confirm .ai-badger/ has changes beyond manifest; check git status |
open_pr.py — gh not authenticated |
gh auth login or set GITHUB_TOKEN |
open_pr.py — branch already exists |
Delete the remote branch (git push origin --delete <branch>) or use a new slug |
open_pr.py — push rejected |
Pull latest, rebase, force-push (draft branch only) |
index_build.py / validate.py error after placing files |
Fix the placed files, re-run index build + validate |
After applying a fix, re-run the failed step and continue the flow. If it
succeeds, report what was fixed.
Recovery failed — offer to create a GitHub issue. Follow
.ai-badger/skills/welcome-ai-badger/references/reporting-a-framework-bug.md when a fix
does not recover the failure: ask
permission first, gate on gh being installed and authenticated, sanitize the config
before including it. Never create the issue without explicit user approval — that rule
holds even if the reference file is not present.
Verification Checklist
1---2name: feed-badger3description: Use when something learned in this repo belongs in the ai-badger framework itself — a new skill, persona, invariant, instruction or fix that is project-agnostic — and the user wants to contribute it back. Opens a draft PR against the framework; refuses anything project-specific.4license: MIT5---67# feed-badger89The reverse of `welcome-ai-badger`: it finds framework-managed content you have added or10changed in a project, keeps only what is genuinely reusable, generalizes it, and contributes it11back to `ai-badger` as a **draft PR** for human review.1213## Responsibility split1415- **Scripts (mechanical):** `detect_additions.py` diffs `.ai-badger/` against `manifest.json`16 and lists candidates; `open_pr.py` does the git branch/commit/push + `gh pr create --draft`.17- **You (creative):** classify each candidate (agnostic / generalizable / project-specific),18 drop project-specific ones with a reason, **generalize** the keepers (strip project paths,19 domain terms, repo names), and **place** each into the correct `{stack}/{feature}/` path in an20 ai-badger checkout.2122## Flow23241. **Detect candidates** (from the target repo root):25 ```bash26 python3 "$AI_BADGER/features/common/skills/feed-badger/scripts/detect_additions.py" --target . --root "$AI_BADGER"27 ```28 Emits `new` (files not from the framework) and `changed` (files edited beyond the scaffold)29 candidates, by feature.30312. **Classify & generalize.** For each candidate decide agnostic / generalizable /32 project-specific. Drop project-specific ones (state why). For the keepers, rewrite to remove33 anything project-coupled — no repo names, no domain nouns, no absolute paths. Decide the34 target stack (or `common`) and feature. A brand-new stack or feature is allowed.35363. **Place into an ai-badger checkout.** Clone or reuse a checkout of `Arasz/ai-badger`, write37 each generalized file to its `{stack}/{feature}/` path, then regenerate the index:38 ```bash39 python3 "<checkout>/tooling/index_build.py"40 python3 "<checkout>/tooling/validate.py" --all41 ```42434. **Open a draft PR.** Write a PR body summarizing each contribution and why it is agnostic,44 then:45 ```bash46 python3 "$AI_BADGER/features/common/skills/feed-badger/scripts/open_pr.py" \47 --checkout <checkout> --branch feed/<slug> \48 --title "feed: <summary>" --body-file <body.md> --repo Arasz/ai-badger \49 --path features/<stack>/<feature>/<name> --path index.json50 ```51 `--path` is **required and repeatable**: name every path you placed, plus `index.json` if52 you regenerated it. Only declared paths are staged, so an unrelated dirty file in the53 checkout cannot ride along in the PR.5455 Every declared path is scanned for credential-shaped literals before anything is staged.56 A finding refuses the PR and names the file and the shape — never the matched text. It is57 a guard, not proof: it checks known literal shapes, so a clean run is not a certificate.5859 Use `--dry-run` to preview the git/gh commands without executing (useful for testing).6061## Rules6263- **Draft, always.** Contributions land as draft PRs; a human reviews and merges. Never64 auto-merge.65- **Agnostic bar is high.** When unsure whether something is reusable, keep it in the project,66 not the framework. Better to under-contribute than to pollute the catalog.67- **Provenance drives detection.** `feed-badger` only works on repos scaffolded by ai-badger68 (those with `.ai-badger/manifest.json`).6970## Gotchas7172- **Draft PR, always.** A human reviews and merges; never auto-merge.73- **`--path` is required and repeatable.** Only declared paths are staged, so an unrelated dirty74 file cannot ride along in the PR.75- **The credential scan is a guard, not proof.** It checks known literal shapes; a clean run is76 not a certificate.77- **The agnostic bar is high.** When unsure, keep it in the project, not the framework.7879## Error Recovery8081When any script in the feed flow (`detect_additions.py`, `open_pr.py`) exits82non-zero or emits an error, attempt recovery before surfacing the failure.83841. **Parse the error.** Scripts emit structured JSON — read the `error` field to85 classify the failure.86872. **Attempt automatic recovery.** Try the applicable fix, then re-run the88 failed step.8990 | Error | Fix |91 |---|---|92 | `manifest.json` missing or corrupt | Project not scaffolded — run `welcome-ai-badger` first |93 | `detect_additions.py` found no candidates | Confirm `.ai-badger/` has changes beyond manifest; check git status |94 | `open_pr.py` — `gh` not authenticated | `gh auth login` or set `GITHUB_TOKEN` |95 | `open_pr.py` — branch already exists | Delete the remote branch (`git push origin --delete <branch>`) or use a new slug |96 | `open_pr.py` — push rejected | Pull latest, rebase, force-push (draft branch only) |97 | `index_build.py` / `validate.py` error after placing files | Fix the placed files, re-run index build + validate |9899 After applying a fix, **re-run the failed step** and continue the flow. If it100 succeeds, report what was fixed.1011023. **Recovery failed — offer to create a GitHub issue.** Follow103 `.ai-badger/skills/welcome-ai-badger/references/reporting-a-framework-bug.md` **when a fix104 does not recover the failure**: ask105 permission first, gate on `gh` being installed and authenticated, sanitize the config106 before including it. **Never create the issue without explicit user approval** — that rule107 holds even if the reference file is not present.108109## Verification Checklist110111- [ ] `detect_additions.py` ran and every candidate was classified — dropped project-specific ones have stated reasons112- [ ] Every keeper generalized — no repo names, domain nouns, or absolute paths113- [ ] Placed files pass `index_build.py` + `validate.py --all` in the checkout114- [ ] Draft PR opened with `--path` naming every placed path (and `index.json` if regenerated)115- [ ] Credential scan clean