Skip to content

feat(ce-plan): reduce token usage by extracting conditional references#489

Merged
tmchow merged 2 commits intomainfrom
tmchow/plan-skill-optimize
Apr 2, 2026
Merged

feat(ce-plan): reduce token usage by extracting conditional references#489
tmchow merged 2 commits intomainfrom
tmchow/plan-skill-optimize

Conversation

@tmchow
Copy link
Copy Markdown
Collaborator

@tmchow tmchow commented Apr 2, 2026

Summary

  • Extract three conditional/late-sequence blocks from ce:plan SKILL.md into on-demand reference files
  • Reduce base skill from 1,023 lines (~15,525 tokens) to 685 lines (~9,971 tokens) — a 36% reduction
  • Add "Conditional and Late-Sequence Extraction" rule to plugin AGENTS.md for future skill optimization

Token savings evidence

ce:plan is an orchestration-heavy skill that makes 20-40+ tool/agent calls per session. Every message exchange carries the full SKILL.md in context. Extracting unused content eliminates that compounding cost:

Extraction Tokens Condition Loaded when
references/deepening-workflow.md ~3,808 Deepening gate passes Phase 5.3.3
references/visual-communication.md ~823 Complex visual patterns Phase 4.4
references/plan-handoff.md ~1,304 Always, but late-sequence Phase 5.3.8

Per-session savings: ~130,000-167,000 context tokens (extracted tokens x messages before they're needed).

Validation

Ran 3 test plans exercising all code paths:

Test Depth deepening-workflow.md visual-communication.md plan-handoff.md
Frontmatter bugfix Lightweight Not read (correct) Not read (correct) Not reached (perm wall)
Gemini CLI target Standard Not read (correct — strong local grounding) Not read (correct) Read #13 of 14 (correct)
Stripe billing Deep Read #6 of 8 (correct — thin grounding + high-risk) Read #2 of 8 (correct — 6 units, non-linear deps) Read #7 of 8 (correct)

Zero premature reference file reads across all tests. All 582 unit tests pass.

Test plan

  • bun test — 582 pass, 0 fail
  • Contract tests updated to verify reference files contain expected behavioral guarantees
  • New contract test verifies SKILL.md stub points to plan-handoff reference
  • Lightweight plan path: deepening skipped, handoff loads at end
  • Standard plan path: deepening skipped (strong grounding), handoff loads at end
  • Deep plan path: all three reference files loaded at correct phases

🤖 Generated with Claude Code

…vings

Extract three large conditional/late-sequence blocks from ce:plan SKILL.md
into on-demand reference files, reducing the base skill from 1,023 lines
(~15,525 tokens) to 685 lines (~9,971 tokens) — a 36% reduction.

For orchestration-heavy skills like ce:plan with 20-40+ tool/agent calls
per session, unused content carried in every message exchange compounds
significantly. This saves ~130,000-167,000 context tokens per planning
session depending on which code paths execute.

Extracted files:
- references/deepening-workflow.md (5.3.3-5.3.7, ~3,808 tok) — loaded
  only when the deepening gate passes
- references/visual-communication.md (4.4, ~823 tok) — loaded only when
  plan has complex visual-worthy content patterns
- references/plan-handoff.md (5.3.8-5.4, ~1,304 tok) — loaded only at
  end of workflow for document review and post-generation options

Also adds a "Conditional and Late-Sequence Extraction" rule to the plugin
AGENTS.md to guide future skill optimization.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2ac5cf51d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@tmchow tmchow changed the title feat(ce-plan): extract conditional blocks to references/ for token savings feat(ce-plan): optimize skill to for token savings by extracting conditional references Apr 2, 2026
@tmchow tmchow changed the title feat(ce-plan): optimize skill to for token savings by extracting conditional references feat(ce-plan): reduce token usage by extracting conditional references Apr 2, 2026
The 4.4 stub was missing the Key Technical Decisions and Alternative
Approaches triggers. Restores the complete condition set so the agent
loads visual-communication.md for all cases the reference file covers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tmchow tmchow merged commit fd562a0 into main Apr 2, 2026
2 checks passed
@github-actions github-actions bot mentioned this pull request Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant