From f744b797efca368c986e4c8595e09a4f75e57a11 Mon Sep 17 00:00:00 2001 From: Kieran Klaassen Date: Sun, 8 Feb 2026 22:28:51 -0600 Subject: [PATCH] =?UTF-8?q?Reduce=20context=20token=20usage=20by=2079%=20?= =?UTF-8?q?=E2=80=94=20fix=20silent=20component=20exclusion=20(#161)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update create-agent-skills to match 2026 official docs, add /triage-prs command - Rewrite SKILL.md to document that commands and skills are now merged - Add new frontmatter fields: disable-model-invocation, user-invocable, context, agent - Add invocation control table and dynamic context injection docs - Fix skill-structure.md: was incorrectly recommending XML tags over markdown headings - Update official-spec.md with complete 2026 specification - Add local /triage-prs command for PR triage workflow - Add PR triage plan document Co-Authored-By: Claude Opus 4.6 * [2.31.0] Reduce context token usage by 79%, include recent community contributions The plugin was consuming 316% of Claude Code's description character budget (~50,500 chars vs 16,000 limit), causing components to be silently excluded. Now at 65% (~10,400 chars) with all components visible. Changes: - Trim all 29 agent descriptions (move examples to body) - Add disable-model-invocation to 18 manual commands - Add disable-model-invocation to 6 manual skills - Include recent community contributions in changelog - Fix component counts (29 agents, 24 commands, 18 skills) Contributors: @trevin, @terryli, @robertomello, @zacwilliams, @aarnikoskela, @samxie, @davidalley Co-Authored-By: Claude Opus 4.6 * Fix: keep disable-model-invocation off commands called by /lfg, rename xcode-test - Remove disable-model-invocation from test-browser, feature-video, resolve_todo_parallel — these are called programmatically by /lfg and /slfg - Rename xcode-test to test-xcode to match test-browser naming convention Co-Authored-By: Claude Opus 4.6 * Fix: keep git-worktree skill auto-invocable (used by /workflows:work) Co-Authored-By: Claude Opus 4.6 * feat(converter): support disable-model-invocation frontmatter Parse disable-model-invocation from command and skill frontmatter. Commands/skills with this flag are excluded from OpenCode command maps and Codex prompt/skill generation, matching Claude Code behavior where these components are user-only invocable. Bump converter version to 0.3.0. Co-Authored-By: Claude Opus 4.6 --------- Co-authored-by: Claude Opus 4.6 --- .claude-plugin/marketplace.json | 4 +- .claude/commands/triage-prs.md | 193 ++++++++ ...026-02-08-feat-pr-triage-and-merge-plan.md | 128 +++++ ...-reduce-plugin-context-token-usage-plan.md | 212 +++++++++ package.json | 2 +- .../.claude-plugin/plugin.json | 4 +- plugins/compound-engineering/CHANGELOG.md | 26 ++ plugins/compound-engineering/CLAUDE.md | 7 +- .../design/design-implementation-reviewer.md | 17 +- .../agents/design/design-iterator.md | 29 +- .../agents/design/figma-design-sync.md | 20 +- .../agents/docs/ankane-readme-writer.md | 17 +- .../research/best-practices-researcher.md | 17 +- .../research/framework-docs-researcher.md | 17 +- .../agents/research/git-history-analyzer.md | 17 +- .../agents/research/learnings-researcher.md | 23 +- .../agents/research/repo-research-analyst.md | 23 +- .../agents/review/agent-native-reviewer.md | 17 +- .../agents/review/architecture-strategist.md | 17 +- .../agents/review/code-simplicity-reviewer.md | 17 +- .../agents/review/data-integrity-guardian.md | 17 +- .../agents/review/data-migration-expert.md | 17 +- .../review/deployment-verification-agent.md | 17 +- .../agents/review/dhh-rails-reviewer.md | 23 +- .../review/julik-frontend-races-reviewer.md | 41 +- .../agents/review/kieran-python-reviewer.md | 31 +- .../agents/review/kieran-rails-reviewer.md | 31 +- .../review/kieran-typescript-reviewer.md | 31 +- .../review/pattern-recognition-specialist.md | 17 +- .../agents/review/performance-oracle.md | 29 +- .../agents/review/schema-drift-detector.md | 17 +- .../agents/review/security-sentinel.md | 23 +- .../workflow/bug-reproduction-validator.md | 17 +- .../agents/workflow/every-style-editor.md | 2 +- .../agents/workflow/pr-comment-resolver.md | 17 +- .../agents/workflow/spec-flow-analyzer.md | 23 +- .../commands/agent-native-audit.md | 1 + .../commands/changelog.md | 1 + .../commands/create-agent-skill.md | 1 + .../commands/deploy-docs.md | 1 + .../commands/generate_command.md | 1 + .../commands/heal-skill.md | 1 + plugins/compound-engineering/commands/lfg.md | 1 + .../commands/release-docs.md | 1 + .../commands/report-bug.md | 1 + .../commands/reproduce-bug.md | 1 + .../commands/resolve_parallel.md | 1 + .../commands/resolve_pr_parallel.md | 49 -- plugins/compound-engineering/commands/slfg.md | 1 + .../commands/technical_review.md | 1 + .../commands/{xcode-test.md => test-xcode.md} | 3 +- .../compound-engineering/commands/triage.md | 1 + .../skills/compound-docs/SKILL.md | 1 + .../skills/create-agent-skills/SKILL.md | 378 +++++++-------- .../references/official-spec.md | 205 ++++---- .../references/skill-structure.md | 436 +++++------------- .../skills/file-todos/SKILL.md | 1 + .../skills/orchestrating-swarms/SKILL.md | 1 + .../skills/resolve-pr-parallel/SKILL.md | 89 ++++ .../scripts/get-pr-comments | 68 +++ .../scripts/resolve-pr-thread | 23 + .../skills/skill-creator/SKILL.md | 1 + src/converters/claude-to-codex.ts | 3 +- src/converters/claude-to-opencode.ts | 1 + src/parsers/claude.ts | 4 + src/types/claude.ts | 2 + tests/claude-parser.test.ts | 26 +- tests/codex-converter.test.ts | 38 ++ tests/converter.test.ts | 15 + .../commands/disabled-command.md | 7 + .../skills/disabled-skill/SKILL.md | 7 + 71 files changed, 1765 insertions(+), 767 deletions(-) create mode 100644 .claude/commands/triage-prs.md create mode 100644 docs/plans/2026-02-08-feat-pr-triage-and-merge-plan.md create mode 100644 docs/plans/2026-02-08-refactor-reduce-plugin-context-token-usage-plan.md delete mode 100644 plugins/compound-engineering/commands/resolve_pr_parallel.md rename plugins/compound-engineering/commands/{xcode-test.md => test-xcode.md} (99%) create mode 100644 plugins/compound-engineering/skills/resolve-pr-parallel/SKILL.md create mode 100755 plugins/compound-engineering/skills/resolve-pr-parallel/scripts/get-pr-comments create mode 100755 plugins/compound-engineering/skills/resolve-pr-parallel/scripts/resolve-pr-thread create mode 100644 tests/fixtures/sample-plugin/commands/disabled-command.md create mode 100644 tests/fixtures/sample-plugin/skills/disabled-skill/SKILL.md diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index ce32527..92f3624 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -11,8 +11,8 @@ "plugins": [ { "name": "compound-engineering", - "description": "AI-powered development tools that get smarter with every use. Make each unit of engineering work easier than the last. Includes 29 specialized agents, 25 commands, and 16 skills.", - "version": "2.30.0", + "description": "AI-powered development tools that get smarter with every use. Make each unit of engineering work easier than the last. Includes 29 specialized agents, 24 commands, and 18 skills.", + "version": "2.31.0", "author": { "name": "Kieran Klaassen", "url": "https://github.com/kieranklaassen", diff --git a/.claude/commands/triage-prs.md b/.claude/commands/triage-prs.md new file mode 100644 index 0000000..45e9717 --- /dev/null +++ b/.claude/commands/triage-prs.md @@ -0,0 +1,193 @@ +--- +name: triage-prs +description: Triage all open PRs with parallel agents, label, group, and review one-by-one +argument-hint: "[optional: repo owner/name or GitHub PRs URL]" +disable-model-invocation: true +allowed-tools: Bash(gh *), Bash(git log *) +--- + +# Triage Open Pull Requests + +Review, label, and act on all open PRs for a repository using parallel review agents. Produces a grouped triage report, applies labels, cross-references with issues, and walks through each PR for merge/comment decisions. + +## Step 0: Detect Repository + +Detect repo context: +- Current repo: !`gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null || echo "no repo detected"` +- Current branch: !`git branch --show-current 2>/dev/null` + +If `$ARGUMENTS` contains a GitHub URL or `owner/repo`, use that instead. Confirm the repo with the user if ambiguous. + +## Step 1: Gather Context (Parallel) + +Run these in parallel: + +1. **List all open PRs:** + ```bash + gh pr list --repo OWNER/REPO --state open --limit 50 + ``` + +2. **List all open issues:** + ```bash + gh issue list --repo OWNER/REPO --state open --limit 50 + ``` + +3. **List existing labels:** + ```bash + gh label list --repo OWNER/REPO --limit 50 + ``` + +4. **Check recent merges** (to detect duplicate/superseded PRs): + ```bash + git log --oneline -20 main + ``` + +## Step 2: Batch PRs by Theme + +Group PRs into review batches of 4-6 based on apparent type: + +- **Bug fixes** - titles with `fix`, `bug`, error descriptions +- **Features** - titles with `feat`, `add`, new functionality +- **Documentation** - titles with `docs`, `readme`, terminology +- **Configuration/Setup** - titles with `config`, `setup`, `install` +- **Stale/Old** - PRs older than 30 days + +## Step 3: Parallel Review (Team of Agents) + +Spawn one review agent per batch using the Task tool. Each agent should: + +For each PR in their batch: +1. Run `gh pr view --repo OWNER/REPO --json title,body,files,additions,deletions,author,createdAt` +2. Run `gh pr diff --repo OWNER/REPO ` (pipe to `head -200` for large diffs) +3. Determine: + - **Description:** 1-2 sentence summary of the change + - **Label:** Which existing repo label fits best + - **Action:** merge / request changes / close / needs discussion + - **Related PRs:** Any PRs in this or other batches that touch the same files or feature + - **Quality notes:** Code quality, test coverage, staleness concerns + +Instruct each agent to: +- Flag PRs that touch the same files (potential merge conflicts) +- Flag PRs that duplicate recently merged work +- Flag PRs that are part of a group solving the same problem differently +- Report findings as a markdown table +- Send findings back via message when done + +## Step 4: Cross-Reference Issues + +After all agents report, match issues to PRs: + +- Check if any PR title/body mentions `Fixes #X` or `Closes #X` +- Check if any issue title matches a PR's topic +- Look for duplicate issues (same bug reported twice) + +Build a mapping table: +``` +| Issue | PR | Relationship | +|-------|-----|--------------| +| #158 | #159 | PR fixes issue | +``` + +## Step 5: Identify Themes + +Group all issues into themes (3-6 themes): +- Count issues per theme +- Note which themes have PRs addressing them and which don't +- Flag themes with competing/overlapping PRs + +## Step 6: Compile Triage Report + +Present a single report with: + +1. **Summary stats:** X open PRs, Y open issues, Z themes +2. **PR groups** with recommended actions: + - Group name and related PRs + - Per-PR: #, title, author, description, label, action +3. **Issue-to-PR mapping** +4. **Themes across issues** +5. **Suggested cleanup:** spam issues, duplicates, stale items + +## Step 7: Apply Labels + +After presenting the report, ask user: + +> "Apply these labels to all PRs on GitHub?" + +If yes, run `gh pr edit --repo OWNER/REPO --add-label "