Skip to content

Trim Claude Code skill descriptions to cut per-turn token cost#66444

Merged
jedcunningham merged 1 commit intoapache:mainfrom
astronomer:trim-skill-descriptions
May 5, 2026
Merged

Trim Claude Code skill descriptions to cut per-turn token cost#66444
jedcunningham merged 1 commit intoapache:mainfrom
astronomer:trim-skill-descriptions

Conversation

@jedcunningham
Copy link
Copy Markdown
Member

The description and when_to_use frontmatter fields of every available SKILL.md are loaded into the Claude Code system prompt at the start of every turn so it can route to the right skill; the body of each skill only loads on invocation. So frontmatter is the lever for steady-state context cost.

Trims maintainer-review, pr-triage, and pr-stats to keep only what's useful for routing — what the skill does, how it picks its targets where that matters (maintainer-review's "my reviews" working list, pr-triage's ready for maintainer review label), and the trigger phrases. Drops file-path cross-refs, mutation names, "successor to breeze X" history, and verbose action enumerations — all still present in the SKILL.md bodies, which are unchanged.

Saves roughly 500 tokens off the available-skills listing loaded each turn:

maintainer-review: ~420 → ~170 tokens
pr-triage:         ~300 → ~125 tokens
pr-stats:          ~170 → ~105 tokens

The maintainer-review skill was spitting out an warning before as well in /doctor:

Some skill descriptions will be shortened
      1 description exceeds the per-entry cap: maintainer-review

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.7)

Generated-by: Claude Code (Opus 4.7) following the guidelines

The `description` and `when_to_use` fields in each SKILL.md are loaded
into the system prompt every turn so Claude can route to the right
skill; the body only loads when the skill is invoked. Frontmatter is
the lever for steady-state context cost.

Trims maintainer-review, pr-triage, and pr-stats to keep only what's
useful for routing: what the skill does, how it picks its targets
where that matters (maintainer-review's "my reviews" working list,
pr-triage's `ready for maintainer review` label), and the trigger
phrases that hint when to invoke it. Drops file-path cross-refs,
mutation names, "successor to breeze X" history, and verbose action
enumerations — all still present in the SKILL.md bodies, which are
unchanged.

Saves roughly 500 tokens off the available-skills listing loaded each
turn:

  maintainer-review: ~420 → ~170 tokens
  pr-triage:         ~300 → ~125 tokens
  pr-stats:          ~170 → ~105 tokens
@boring-cyborg boring-cyborg Bot added area:dev-tools backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch labels May 5, 2026
@jedcunningham jedcunningham merged commit f9ae53c into apache:main May 5, 2026
66 checks passed
@jedcunningham jedcunningham deleted the trim-skill-descriptions branch May 5, 2026 21:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Backport failed to create: v3-2-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-2-test Commit Link

You can attempt to backport this manually by running:

cherry_picker f9ae53c v3-2-test

This should apply the commit to the v3-2-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

@jedcunningham
Copy link
Copy Markdown
Member Author

@potiuk it may be worth doing a similar pass on the skills in airflow-steward.

@potiuk
Copy link
Copy Markdown
Member

potiuk commented May 5, 2026

@potiuk it may be worth doing a similar pass on the skills in airflow-steward.

Oh absolutely. I will port it there. To be honest I have not done yet "optimization" phase - but I noticed that the agent is very chatty for those (i did not have to worry about the tokens yet - but yes optimization and making those more affordable is a good idea and we have it definitely plnned.

@potiuk
Copy link
Copy Markdown
Member

potiuk commented May 5, 2026

@potiuk it may be worth doing a similar pass on the skills in airflow-steward.

Oh absolutely. I will port it there. To be honest I have not done yet "optimization" phase - but I noticed that the agent is very chatty for those (i did not have to worry about the tokens yet - but yes optimization and making those more affordable is a good idea and we have it definitely plnned.

BTW. My plan is to actulally incorporate https://github.com/JuliusBrussee/caveman/blob/main/README.md ... THIS is a real saving :)

@jedcunningham
Copy link
Copy Markdown
Member Author

Haha, reminds me of Kevins small talk from the office!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants