# Theme Rebase

Rebase all theme-* branches onto main, one commit per theme, preserving each theme's...

- Repository: https://github.com/yournextstore/yournextstore (5539 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-10-31
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add yournextstore/yournextstore --skill theme-rebase -g -a claude-code -y`
Codex: `npx skills add yournextstore/yournextstore --skill theme-rebase -g -a codex -y`
Cursor: `npx skills add yournextstore/yournextstore --skill theme-rebase -g -a cursor -y`
Gemini CLI: `npx skills add yournextstore/yournextstore --skill theme-rebase -g -a gemini-cli -y`

## Description

Rebase all theme-* branches onto main, one commit per theme, preserving each theme's visual identity. A script does the mechanics and a headless agent resolves only what needs judgment; pushes with backup tags. Run as a scheduled task or one-off.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Rebase theme branches onto main

Each `theme-*` branch is one commit on top of `main`: the theme's own `theme NNN: …` commit (README, "Themes"). [`theme-rebase.sh`](theme-rebase.sh) rebuilds every theme that way on the current `main`. For each theme, in its own worktree, it:

1. squash-merges the theme onto `main`: one 3-way merge, however many commits the branch has;
2. settles what needs no judgment: `bun.lock`, `package.json`, and every path only copied commits touched, which take main's side; then runs the [codemods](codemods/) over the merged files and over both sides of each remaining conflict, so a rewrite main made everywhere stops conflicting with the theme's edits around it;
3. starts one headless Claude session for what is left, with [rules.md](rules.md) as its instructions;
4. runs `bun run check` and `bun run build`, resuming the session once on a failure;
5. commits with the theme commit's message and author, and sends anything doubtful to review.

Nothing leaves the machine until `push`.

## Run it

```bash
S=.agents/skills/theme-rebase/theme-rebase.sh
bash $S run theme-002 theme-003   # or --all
bash $S push                      # the last run's ok themes, one at a time
bash $S clean [theme…]            # drop leftover worktrees and theme-rebase/* branches
```

| Setting | Default | |
|---|---|---|
| `JOBS` | 3 | themes in parallel |
| `AGENT` | `claude` | `none`: stop at `needs-agent` instead of starting a session |
| `BUILD` | 1 | 0 skips `bun run build` |
| `AGENT_BUDGET` | 10 | USD cap per agent session |
| `AGENT_MODEL` | `claude-sonnet-5-5` | `claude-opus-5-5` for a theme Sonnet got wrong |

The build reads live store data, so it needs `YNS_API_KEY` in `.env`. A free census of what a run would hit: `AGENT=none BUILD=0 bash $S run --all`.

Roll a large run out in batches of about 20: run, read the table, push, then the next batch. A scheduled run is `run --all`, then `push`, then the table as the report.

## Statuses

The rest: https://github.com/yournextstore/yournextstore/blob/HEAD/.agents/skills/theme-rebase/SKILL.md
