sensei
npx skills add https://github.com/spboyer/sensei --skill sensei
Agent 安装分布
Skill 文档
Sensei
“A true master teaches not by telling, but by refining.”
Automates skill frontmatter improvement using the Ralph loop pattern – iteratively improving skills until they reach Medium-High compliance with passing tests.
Help
When user says “sensei help” or asks how to use sensei:
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â SENSEI - Skill Frontmatter Compliance Improver â
â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ£
â â
â USAGE: â
â Run sensei on <skill-name> # Single skill â
â Run sensei on <skill-name> --fast # Skip tests â
â Run sensei on <skill1>, <skill2> # Multiple skills â
â Run sensei on all Low-adherence skills # Batch by score â
â Run sensei on all skills # All skills â
â â
â WHAT IT DOES: â
â 1. READ - Load skill's SKILL.md and count tokens â
â 2. SCORE - Check compliance (Low/Medium/Medium-High/High) â
â 3. SCAFFOLD- Create tests from template if missing â
â 4. IMPROVE - Add USE FOR triggers + DO NOT USE FOR â
â 5. TEST - Run tests, fix if needed â
â 6. TOKENS - Check token budget â
â 7. SUMMARY - Show before/after comparison â
â 8. PROMPT - Ask: Commit, Create Issue, or Skip? â
â 9. REPEAT - Until Medium-High score achieved â
â â
â TARGET SCORE: Medium-High â
â â Description > 150 chars â
â â Has "USE FOR:" trigger phrases â
â â Has "DO NOT USE FOR:" anti-triggers â
â â Has "INVOKES:" for tool relationships (optional) â
â â SKILL.md < 500 tokens (soft limit) â
â â
â MCP INTEGRATION (when INVOKES present): â
â â Has "MCP Tools Used" table â
â â Has Prerequisites section â
â â Has CLI fallback pattern â
â â No skill-tool name collision â
â â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Configuration
Sensei uses these defaults (override by specifying in your prompt):
| Setting | Default | Description |
|---|---|---|
| Skills directory | skills/ or .github/skills/ |
Where SKILL.md files live |
| Tests directory | tests/ |
Where test files live |
| Token soft limit | 500 | Target for SKILL.md |
| Token hard limit | 5000 | Maximum for SKILL.md |
| Target score | Medium-High | Minimum compliance level |
| Max iterations | 5 | Per-skill loop limit |
Auto-detect skills directory by checking (in order):
skills/in project root.github/skills/- User-specified path
Invocation Modes
Single Skill
Run sensei on my-skill-name
Multiple Skills
Run sensei on skill-a, skill-b, skill-c
By Adherence Level
Run sensei on all Low-adherence skills
Run sensei on all Medium-adherence skills
All Skills
Run sensei on all skills
Fast Mode (Skip Tests)
Run sensei on my-skill --fast
The Ralph Loop
For each skill, execute this loop until score >= Medium-High:
Step 1: READ
Load the skill’s current state:
{skills-dir}/{skill-name}/SKILL.md
{tests-dir}/{skill-name}/ (if exists)
Run token count:
npm run tokens -- count {skills-dir}/{skill-name}/SKILL.md
Step 2: SCORE
Assess compliance by checking the frontmatter for:
- Description length (>= 150 chars)
- “USE FOR:” trigger phrases
- “DO NOT USE FOR:” anti-triggers
- “INVOKES:” routing clarity (optional)
See references/scoring.md for detailed criteria.
Step 3: CHECK
If score >= Medium-High AND tests pass â go to SUMMARY step.
Step 4: SCAFFOLD (if needed)
If {tests-dir}/{skill-name}/ doesn’t exist, create test scaffolding using templates from references/test-templates/.
Step 5: IMPROVE FRONTMATTER
Enhance the SKILL.md description to include:
- Trigger phrases – “USE FOR:” followed by specific keywords
- Anti-triggers – “DO NOT USE FOR:” with scenarios that should use other skills
- Keep description under 1024 characters
Template:
---
name: skill-name
description: |
[1-2 sentence description of what the skill does]
USE FOR: [phrase1], [phrase2], [phrase3], [phrase4], [phrase5].
DO NOT USE FOR: [scenario1] (use other-skill), [scenario2].
---
Step 6: IMPROVE TESTS
Update test prompts to match new frontmatter:
shouldTriggerPrompts– 5+ prompts matching “USE FOR:” phrasesshouldNotTriggerPrompts– 5+ prompts matching “DO NOT USE FOR:”
Step 7: VERIFY
Run tests (skip if --fast flag):
# Framework-specific command based on project
npm test -- --testPathPattern={skill-name} # Jest
pytest tests/{skill-name}/ # pytest
waza run tests/{skill-name}/trigger_tests.yaml # Waza
Step 8: TOKENS
Check token budget:
npm run tokens -- check {skills-dir}/{skill-name}/SKILL.md
Budget guidelines:
- SKILL.md: < 500 tokens (soft), < 5000 (hard)
- references/*.md: < 1000 tokens each
Step 8b: MCP INTEGRATION (if INVOKES present)
When description contains INVOKES:, check:
- MCP Tools Used table – Does skill body have the table?
- Prerequisites section – Are requirements documented?
- CLI fallback – Is there a fallback when MCP unavailable?
- Name collision – Does skill name match an MCP tool?
If checks fail, add missing sections using patterns from mcp-integration.md.
Step 9: SUMMARY
Display before/after comparison:
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â SENSEI SUMMARY: {skill-name} â
â âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ£
â BEFORE AFTER â
â ââââââ âââââ â
â Score: Low Score: Medium-High â
â Tokens: 142 Tokens: 385 â
â Triggers: 0 Triggers: 5 â
â Anti-triggers: 0 Anti-triggers: 3 â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Step 10: PROMPT USER
Ask how to proceed:
- [C] Commit – Save with message
sensei: improve {skill-name} frontmatter - [I] Create Issue – Open issue with summary and suggestions
- [S] Skip – Discard changes, move to next skill
Step 11: REPEAT or EXIT
- If score < Medium-High AND iterations < 5 â go to Step 2
- If iterations >= 5 â timeout, show summary, move to next skill
Scoring Quick Reference
| Score | Requirements |
|---|---|
| Low | Description < 150 chars OR no triggers |
| Medium | Description >= 150 chars AND has trigger keywords |
| Medium-High | Has “USE FOR:” AND “DO NOT USE FOR:” |
| High | Medium-High + routing clarity (INVOKES/FOR SINGLE OPERATIONS) |
MCP Integration Score (when INVOKES present)
| Check | Status |
|---|---|
| MCP Tools Used table | â/â |
| Prerequisites section | â/â |
| CLI fallback pattern | â/â |
| No name collision | â/â |
See references/scoring.md for full criteria. See references/mcp-integration.md for MCP patterns.
Frontmatter Patterns
Skill Classification Prefix
Add a prefix to clarify the skill type:
**WORKFLOW SKILL**– Multi-step orchestration**UTILITY SKILL**– Single-purpose helper**ANALYSIS SKILL**– Read-only analysis/reporting
Routing Clarity (for High score)
When skills interact with MCP tools or other skills, add:
INVOKES:– What tools/skills this skill callsFOR SINGLE OPERATIONS:– When to bypass this skill
Quick Example
Before (Low):
description: 'Process PDF files'
After (High with routing):
description: |
**WORKFLOW SKILL** - Process PDF files including text extraction, rotation, and merging.
USE FOR: "extract PDF text", "rotate PDF", "merge PDFs", "PDF to text".
DO NOT USE FOR: creating PDFs from scratch (use document-creator),
image extraction (use image-extractor).
INVOKES: pdf-tools MCP for extraction, file-system for I/O.
FOR SINGLE OPERATIONS: Use pdf-tools MCP directly for simple extractions.
See references/examples.md for more before/after transformations.
Commit Messages
sensei: improve {skill-name} frontmatter
Reference Documentation
- scoring.md – Detailed scoring criteria and algorithm
- mcp-integration.md – MCP tool integration patterns
- loop.md – Ralph loop workflow details
- examples.md – Before/after transformation examples
- configuration.md – Project setup patterns
- test-templates/ – Test scaffolding templates
- test-templates/waza.md – Waza trigger test format
Built-in Scripts
Run npm run tokens help for full usage.
Token Commands
npm run tokens count # Count all markdown files
npm run tokens check # Check against token limits
npm run tokens suggest # Get optimization suggestions
npm run tokens compare # Compare with git history
Configuration
Create .token-limits.json to customize limits:
{
"defaults": { "SKILL.md": 500, "references/**/*.md": 1000 },
"overrides": { "README.md": 3000 }
}