en un clic
jwx-companion-bulk
// Apply bulk operations across all jwx companion modules. Args: <instructions...>
// Apply bulk operations across all jwx companion modules. Args: <instructions...>
| name | jwx-companion-bulk |
| description | Apply bulk operations across all jwx companion modules. Args: <instructions...> |
Apply a uniform operation across jwx companion modules (github.com/jwx-go/*). Handles cloning, branching, applying changes, verifying, committing, and reporting.
/jwx-companion-bulk <instructions...>
$INSTRUCTIONS (required) — what to do across companion modules. Free-form text.--modules=<name,name,...> — target only these modules (comma-separated names)--ref-module=<name> — use this module as the reference/template for file-copy operations--pr — push branches and create PRs (off by default; commits locally only)--dry-run — show what would change without modifying anythingIf instructions are ambiguous, ask the user before proceeding.
companions.yaml from the project root.modules list. Each entry has: name, repo, branch.--modules= was provided, filter to only those names. Error if a name is not found.For each module in the (filtered) list:
If $PROJECT/.companions/repo/<name>/ does not exist:
cd $PROJECT
git clone <repo> .companions/repo/<name>
If it already exists, update it:
cd $PROJECT/.companions/repo/<name>
git fetch origin
Determine the default branch for each module:
branch is set in the config, use that.origin/HEAD:
cd $PROJECT/.companions/repo/<name>
git symbolic-ref refs/remotes/origin/HEAD
This returns e.g. refs/remotes/origin/develop/v4 — strip the prefix.origin/HEAD is not set, query GitHub:
gh repo view <org>/<name> --json defaultBranchRef --jq .defaultBranchRef.name
Checkout the default branch:
cd $PROJECT/.companions/repo/<name>
git checkout <default-branch>
cd $PROJECT/.companions/repo/<name>
git pull --ff-only
Run these on ALL targeted modules BEFORE modifying ANY:
Clean working tree: git status --porcelain must produce empty output.
If any module is dirty, report which ones and STOP.
Remote reachable (only if --pr): git ls-remote origin HEAD must succeed.
gh auth (only if --pr): gh auth status must succeed.
If pre-flight fails, report the failures and stop. Do not partially proceed.
Decide whether this is a mechanical or creative operation:
Heuristics:
When unsure, ask the user: "Same mechanical change per module, or independent work per module?"
--ref-module if specified).cd $PROJECT/.companions/repo/<name>
git checkout -b <branch-name> <default-branch>
Use ordinary branch naming: <category>-<short-description> (e.g. chore-bump-jwx-dep).go.mod):
cd $PROJECT/.companions/repo/<name>
go build ./...
cd $PROJECT/.companions/repo/<name>
golangci-lint run ./...
git checkout .), delete the branch,
record failure, continue to next module.$PROJECT/.companions/repo/<name>For each module where changes were made and verification passed:
cd $PROJECT/.companions/repo/<name>
git add <files>
--pr)For each module where changes were committed:
cd $PROJECT/.companions/repo/<name>
git push -u origin <branch-name>
cd $PROJECT/.companions/repo/<name>
gh pr create --title "<title>" --body "<body>"
Target the module's default branch.Always end with a report:
## Companion Module Bulk Operation Report
**Operation**: <summary of instructions>
**Date**: YYYY-MM-DD
**Modules targeted**: N
**Succeeded**: X | **Skipped**: Y | **Failed**: Z
| Module | Branch | Status | PR | Notes |
|--------|--------|--------|----|-------|
| ... | ... | success/skipped/failed | URL or — | ... |
### Files Changed
- <list of files modified across modules>
### Errors (if any)
- **<module>**: <error description>
When replicating changes across modules, adapt these patterns:
| Pattern | Adaptation |
|---|---|
Module name in go.mod | Read actual module path from the target's go.mod |
| Module name in CI YAML | Package-specific test paths |
| Import paths | Adjust jwx-go/<proto> to jwx-go/<target> |
| Default branch | Use branch from companions.yaml for each module |
Modules without go.mod (benchmarks) | Skip Go-specific steps (build, lint, dep update) |
| Error | Response |
|---|---|
| Dirty working tree | STOP entirely (pre-flight) |
go build fails after change | Revert, record failure, continue others |
golangci-lint fails after change | Revert, record failure, continue others |
| Module not applicable (e.g. no go.mod for dep update) | Skip, report "not applicable" |
| PR creation fails | Report failure, branch still pushed |
| Git push fails | Report, do not retry, continue others |
| File already matches desired state | Report "already up to date", skip |
go build ./... and golangci-lint run ./... before committing (for modules with go.mod).cd into $PROJECT/.companions/repo/<name> before running ANY command (git, go, golangci-lint) for that module. NEVER use git -C, --git-dir, or --work-tree instead — they don't apply to non-git tools, and the shell's working directory stays in the parent jwx repo so its git context leaks through.&&, ||, ;) in Bash calls.--pr is specified.