From 8d791cd60bf9489c29141526dfa701fc7e8d38f7 Mon Sep 17 00:00:00 2001 From: Sandy Tao Date: Tue, 14 Apr 2026 11:35:49 -0700 Subject: [PATCH 1/2] feat(core): integrate skill-creator into skill extraction agent Give the background skill extraction agent access to activate_skill and run_shell_command so it can leverage the built-in skill-creator's design guidance, scaffolding (init_skill.cjs), and validation (package_skill.cjs) when writing SKILL.md files. - Add ACTIVATE_SKILL_TOOL_NAME and SHELL_TOOL_NAME to the agent's tool set - Remove inline SKILL FORMAT section (now provided by skill-creator) - Add workflow step to activate skill-creator for format/quality guidance - Explicitly instruct agent to skip interactive steps (no ask_user access) --- .../core/src/agents/skill-extraction-agent.ts | 68 ++++++------------- 1 file changed, 21 insertions(+), 47 deletions(-) diff --git a/packages/core/src/agents/skill-extraction-agent.ts b/packages/core/src/agents/skill-extraction-agent.ts index 771c94eb2f2..4aa18af388c 100644 --- a/packages/core/src/agents/skill-extraction-agent.ts +++ b/packages/core/src/agents/skill-extraction-agent.ts @@ -7,11 +7,13 @@ import { z } from 'zod'; import type { LocalAgentDefinition } from './types.js'; import { + ACTIVATE_SKILL_TOOL_NAME, EDIT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, LS_TOOL_NAME, READ_FILE_TOOL_NAME, + SHELL_TOOL_NAME, WRITE_FILE_TOOL_NAME, } from '../tools/tool-names.js'; import { PREVIEW_GEMINI_FLASH_MODEL } from '../config/models.js'; @@ -152,45 +154,6 @@ function buildSystemPrompt(skillsDir: string): string { '- One-off artifact names: bug IDs, branch names, timestamps, exact incident strings', '', '============================================================', - 'SKILL FORMAT', - '============================================================', - '', - 'Each skill is a directory containing a SKILL.md file with YAML frontmatter', - 'and optional supporting scripts.', - '', - 'Directory structure:', - ` ${skillsDir}//`, - ' SKILL.md # Required entrypoint', - ' scripts/.* # Optional helper scripts (Python stdlib-only or shell)', - '', - 'SKILL.md structure:', - '', - ' ---', - ' name: ', - ' description: <1-2 lines; include concrete triggers in user-like language>', - ' ---', - '', - ' ## When to Use', - ' ', - '', - ' ## Procedure', - ' ', - '', - ' ## Pitfalls and Fixes', - ' likely cause -> fix; only include observed failures>', - '', - ' ## Verification', - ' ', - '', - 'Supporting scripts (optional but recommended when applicable):', - '- Put helper scripts in scripts/ and reference them from SKILL.md', - '- Prefer Python (stdlib only) or small shell scripts', - '- Make scripts safe: no destructive actions, no secrets, deterministic output', - '- Include a usage example in SKILL.md', - '', - 'Naming: kebab-case (e.g., fix-lint-errors, run-migrations).', - '', - '============================================================', 'UPDATING EXISTING SKILLS (PATCHES)', '============================================================', '', @@ -247,20 +210,28 @@ function buildSystemPrompt(skillsDir: string): string { '', `1. Use list_directory on ${skillsDir} to see existing skills.`, '2. If skills exist, read their SKILL.md files to understand what is already captured.', - '3. Scan the session index provided in the query. Look for [NEW] sessions whose summaries', + '3. Use activate_skill to load the "skill-creator" skill. Follow its design guidance', + ' (conciseness, progressive disclosure, frontmatter format, bundled resources) when', + ' writing SKILL.md files. You may also use its init_skill.cjs script to scaffold new', + ' skill directories and package_skill.cjs to validate finished skills.', + ' IMPORTANT: You are a background agent with no user interaction. Skip any interactive', + ' steps in the skill-creator guide (asking clarifying questions, requesting user feedback,', + ' installation prompts, iteration loops). Use only its format and quality guidance.', + '4. Scan the session index provided in the query. Look for [NEW] sessions whose summaries', ' hint at workflows that ALSO appear in other sessions (either [NEW] or [old]) or at a', ' stable recurring repo workflow. Remember: summary similarity alone is NOT enough.', - '4. Apply the minimum signal gate. If recurrence or durability is not visible, report that', + '5. Apply the minimum signal gate. If recurrence or durability is not visible, report that', ' no skill should be created and finish.', - '5. For promising patterns, use read_file on the session file paths to inspect the full', + '6. For promising patterns, use read_file on the session file paths to inspect the full', ' conversation. Confirm the workflow was actually repeated and validated. Read at least', ' two sessions unless the candidate is clearly a stable recurring repo lifecycle workflow.', - '6. For each candidate, verify it meets ALL criteria. Before writing, make sure you can', + '7. For each candidate, verify it meets ALL criteria. Before writing, make sure you can', ' state: future trigger, evidence sessions, recurrence signal, validation signal, and', ' why it is not generic.', - '7. Write new SKILL.md files or update existing ones in your directory using write_file.', + '8. Write new SKILL.md files or update existing ones in your directory.', + ' Use run_shell_command to run init_skill.cjs for scaffolding and package_skill.cjs for validation.', ' For skills that live OUTSIDE your directory, write a .patch file instead (see UPDATING EXISTING SKILLS).', - '8. Write COMPLETE files — never partially update a SKILL.md.', + '9. Write COMPLETE files — never partially update a SKILL.md.', '', 'IMPORTANT: Do NOT read every session. Only read sessions whose summaries suggest a', 'repeated pattern or a stable recurring repo workflow worth investigating. Most runs', @@ -274,8 +245,9 @@ function buildSystemPrompt(skillsDir: string): string { * writes reusable SKILL.md files to the project memory directory. * * This agent is designed to run in the background on session startup. - * It has restricted tool access (file tools only, no shell or user interaction) - * and is prompted to only operate within the skills memory directory. + * It has restricted tool access (file tools, shell, and skill activation — no + * user interaction) and is prompted to only operate within the skills memory + * directory. */ export const SkillExtractionAgent = ( skillsDir: string, @@ -309,12 +281,14 @@ export const SkillExtractionAgent = ( }, toolConfig: { tools: [ + ACTIVATE_SKILL_TOOL_NAME, READ_FILE_TOOL_NAME, WRITE_FILE_TOOL_NAME, EDIT_TOOL_NAME, LS_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, + SHELL_TOOL_NAME, ], }, get promptConfig() { From 4dfeb3366b2c62215f63fba268b35c94fd67950d Mon Sep 17 00:00:00 2001 From: Sandy Tao Date: Tue, 14 Apr 2026 17:26:12 -0700 Subject: [PATCH 2/2] test(evals): assert skill-creator activation and remove stale heading checks Update skill extraction evals to verify the agent activates skill-creator for design guidance. Remove 'When to Use' heading assertions since skill-creator places trigger info in the YAML description field instead. --- evals/skill_extraction.eval.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/evals/skill_extraction.eval.ts b/evals/skill_extraction.eval.ts index 4149f29a67a..28ca557f010 100644 --- a/evals/skill_extraction.eval.ts +++ b/evals/skill_extraction.eval.ts @@ -272,8 +272,12 @@ describe('Skill Extraction', () => { expect(combinedSkills).toContain('npm run predocs:settings'); expect(combinedSkills).toContain('npm run schema:settings'); expect(combinedSkills).toContain('npm run docs:settings'); - expect(combinedSkills).toMatch(/When to Use/i); expect(combinedSkills).toMatch(/Verification/i); + + // Verify the extraction agent activated skill-creator for design guidance. + expect(config.getSkillManager().isSkillActive('skill-creator')).toBe( + true, + ); }, }); @@ -335,7 +339,11 @@ describe('Skill Extraction', () => { expect(combinedSkills).toContain('npm run db:migrate'); expect(combinedSkills).toContain('npm run db:validate'); expect(combinedSkills).toMatch(/rollback/i); - expect(combinedSkills).toMatch(/When to Use/i); + + // Verify the extraction agent activated skill-creator for design guidance. + expect(config.getSkillManager().isSkillActive('skill-creator')).toBe( + true, + ); }, }); });