omp packages

pi-skill-lazy0.5.0

Keep only the skills you need in Pi's system prompt; route the rest through a searchable skill tool.

wrm244 Published 10 hours ago MIT ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-skill-lazy

Keep Pi's system prompt small no matter how many skills you install.

Pi lists every installed skill's name and description in <available_skills> on every turn. That is fine for five skills and expensive for fifty: 57 skills cost roughly 4.8K tokens of prompt on every request, most of it describing skills the current task will never touch.

This extension keeps a short always-listed set in the prompt and moves the rest behind a searchable skill tool. The body of a skill was never in the prompt anyway — Pi always read it on demand — so routing only changes how the model finds a skill, not how it loads one.

before   <available_skills> 57 entries          ~4.8K tokens every turn
after    <available_skills> 5 entries           ~0.9K tokens
         <skill_lazy> 52 skills hidden, use the skill tool   ~110 tokens

Install

pi install npm:pi-skill-lazy

Or try it without installing anything:

pi -e npm:pi-skill-lazy

What the model sees

The prompt keeps the skills you name in alwaysList (by default brainstorming, systematic-debugging, test-driven-development, verification-before-completion, writing-plans), plus one section that says how many skills are hidden and how to reach them:

<skill_lazy>
52 skills are installed but not in this prompt: dart-add-unit-test, dart-build-cli-app, … docx,
drawio-skill, ego-browser, … (+10 more). Before improvising on a request that names a file type,
library, language, format or workflow (a spreadsheet, a PDF, slides, a diagram, Dart), call
skill({action:"search", query:"<the user's own words>"}). If that finds nothing, call
skill({action:"list"}). skill({action:"load", name}) returns the path to read.
</skill_lazy>

The names are printed in full up to 60 hidden skills and sampled after that, so the section stays around 380 tokens whether you have 20 skills or 200. The tool's own rules are kept to the two the section cannot carry, and a budget test in test/prompt.test.ts fails if that cost creeps back.

A request that clearly matches one of them also gets a single line added to that turn, once per skill per session:

skill-lazy: the installed skill "xlsx" looks relevant to this request (Create and edit Excel
workbooks, formulas and charts). Read /Users/you/.pi/agent/skills/xlsx/SKILL.md with the read tool
before starting, and follow it; if it turns out not to fit, call skill({action:"search", query:"…"})
instead.

The tool itself:

Call Result
skill({action:"search", query:"表格"}) ranked matches, best first: - xlsx — /path/SKILL.md — Create and edit spreadsheets.
skill({action:"list"}) every skill name, grouped by source
skill({action:"load", name:"xlsx"}) <skill name="xlsx" location="/path/SKILL.md" baseDir="…" /> — the model then reads that file

load returns a path rather than the file body on purpose: the path is a handful of tokens, the body can be thousands, and Pi's own skill loading works the same way.

Search is multilingual out of the box. Latin text is tokenized and accent-folded (café meets cafe), Chinese, Japanese and Korean runs are tokenized into characters and 2-grams, and the query is mapped to English terms through a built-in alias table (表格 → spreadsheet xlsx, 做个表 → xlsx, 幻灯片/スライド → slide pptx, 调试 → debug), then scored against skill names, tags and descriptions. ~/.pi/agent/skill-lazy.json extends the table with your own aliases, which is the way to cover a language the built-in table does not.

Filler words are dropped and a hit has to match a name, a tag or a description word before it is reported, so help me with this returns "No skill matched" instead of a plausible wrong skill.

Startup banner

Pi's own [Skills] panel lists everything in the agent directory, so it cannot say which skills the prompt kept. The plugin therefore posts one line as soon as the session opens, before anything is typed:

[skill-lazy] 5 skills stay in the prompt; the other 52 of 57 are behind the skill tool.
/skills lists all, /skills search <query> finds one.

It appears once per session, in the transcript, and costs no prompt tokens — the model never sees it. A resumed, forked or reloaded session keeps the banner it already has instead of repeating it. When the host's prompt lists no skills there is nothing to count yet, and the first turn posts the banner from the real catalog instead.

Chat window

You do not need the model to find a skill for you:

/skills                     every skill, `*` marks the ones in the prompt
/skills search 表格         ranked matches, hidden skills included
/skills stats               what is listed, what is hidden, what was loaded
/skills doctor              version, config, split, prompt cost, whether an update exists
/skills reload              re-read the config file
/skills init                write a starter config file

/skills doctor is the one to reach for when something looks off — the banner does not appear, the counts are not what you expect, or an update went to the wrong version:

/skills doctor
plugin: 0.5.0
config: /Users/you/.pi/agent/skill-lazy.json (missing, built-in defaults in use)
enabled: yes
skills: 57 installed
listed in prompt: 5
hidden behind the skill tool: 52
prompt section: 1529 chars (about 382 tokens)
routing: active
published: 0.5.0 (up to date)

/skill:name keeps working for hidden skills — the host resolves skill commands against the installed set, not against the prompt.

Configuration

~/.pi/agent/skill-lazy.json (or $PI_CODING_AGENT_DIR/skill-lazy.json; $PI_SKILL_LAZY_CONFIG points anywhere). Every field is optional — /skills init writes a starter file.

{
  "enabled": true,
  "alwaysList": ["brainstorming", "systematic-debugging", "writing-plans"],
  "alwaysListPatterns": ["dart-*"],
  "alwaysHide": ["fluffy-*"],
  "listAllBelow": 12,
  "maxSearchResults": 5,
  "aliases": { "报表": ["report", "spreadsheet"], "図": ["diagram", "chart"] }
}
Field Default Meaning
enabled true false disables routing entirely — every skill goes back into the prompt
alwaysList the five names above skills kept in the prompt; names that are not installed are ignored
alwaysListPatterns [] glob patterns over skill names ("dart-*"), case-insensitive
alwaysHide [] glob patterns that never enter the prompt, even if listed
listAllBelow 12 below this many installed skills, everything is listed and routing does nothing
maxSearchResults 5 default number of search hits (1–20)
aliases {} extra query → array of terms, merged over the built-in table; the key is matched anywhere in the query (a whole word for Latin keys), and each term is tokenized like normal text
annotatePrompt true when a request clearly matches a hidden skill, add one message to that turn naming the skill and the file to read (once per skill per session)
debug false log the listed/hidden split, and every hint, to stderr

Arrays replace the default, objects merge over it, and a field with the wrong type is ignored — with a warning in /skills doctor — instead of breaking the session. alwaysList is matched case-insensitively and takes plain names, not patterns.

When none of the names in alwaysList is installed, the three skills with the shortest descriptions are kept in the prompt anyway, so the model never starts a session blind. /skills doctor reports that as promoted:.

Picking what stays

  • Keep skills that must fire before the model knows what it is doing: brainstorming, systematic-debugging, test-driven-development. A hidden skill can only be found once a search happens, and a model that is not looking will not search.
  • Hide the bulky, task-specific ones: documents, PDFs, spreadsheets, diagrams, dart-*, flutter-*.
  • Anything you invoke yourself with /skill:name can be hidden — the slash command never needed the prompt entry.

Cost

The router does no file IO per turn: before_agent_start only copies and partitions an array it already has. Tag reading happens once, on the first search, limited to the first 4KB of each SKILL.md, and cached by path and mtime.

On a 57-skill machine: 4.8K tokens of skill listing becomes roughly 0.8K (5 skills plus the section above), plus about 195 tokens for the tool definition and its two rules — and the hidden names are still all readable, so the model can ask for one by name. /skills stats and /skills doctor show the live numbers.

Compatibility

  • Pi 1.7.0 or newer; Node >=22.19.
  • PI_CODING_AGENT_DIR and --agent-dir are both honoured, including a ~ in the path.
  • No runtime dependencies. typebox, @earendil-works/pi-ai, @earendil-works/pi-coding-agent and @earendil-works/pi-tui come from the host.
  • Does not touch /skill: expansion, frontmatter semantics, or your skill files.
  • Removing it restores the previous prompt: nothing is written outside your config file.

License

MIT