feat: add agentskills.io-compatible SKILL.md generation#2365
Open
gauravverma wants to merge 7 commits intospf13:mainfrom
Open
feat: add agentskills.io-compatible SKILL.md generation#2365gauravverma wants to merge 7 commits intospf13:mainfrom
gauravverma wants to merge 7 commits intospf13:mainfrom
Conversation
* feat: add agentskills.io-compatible SKILL.md generation Add GenSkills and GenSkillsDir to the doc package for generating SKILL.md files following the agentskills.io open standard. GenSkills writes a concise SKILL.md with YAML frontmatter and a command summary to any io.Writer. GenSkillsDir creates the full progressive disclosure directory layout with a references/REFERENCE.md containing detailed per-command documentation including usage, examples, and flags. * refactor: generate per-command reference files for progressive disclosure Instead of a single REFERENCE.md, GenSkillsDir now generates one reference file per command under references/ (e.g. myapp_serve.md, myapp_config_get.md). Agents load only the specific command reference they need, keeping context usage minimal per the agentskills.io progressive disclosure recommendation. SKILL.md links to each reference file individually from the command summary table.
5827774 to
070e506
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for SKILLS.md generation
Summary
Adds
GenSkillsandGenSkillsDirto Cobra'sdocpackage, enabling CLI tools built with Cobra to automatically generate agentskills.io-compatibleSKILL.mdfiles. This gives AI agents a standardized way to discover and use any Cobra-powered CLI.Why this matters
AI coding agents (Claude Code, Copilot, Cursor, etc.) are increasingly used to operate CLI tools on behalf of developers. Today, agents either rely on
--helpoutput (verbose, unstructured) or hand-written documentation (often stale). The agentskills.io open standard solves this by defining a machine-readableSKILL.mdformat that agents can discover and consume automatically.Cobra already generates man pages, markdown, YAML, and REST docs from command trees. This PR extends that same pattern to generate agent-optimized documentation — making every Cobra CLI "agent-ready" with a single function call.
What it does
Two new public functions in the
docpackage:GenSkills(cmd, w, config)— Writes a singleSKILL.mdto anyio.Writer. Produces a concise document with YAML frontmatter (name, description, license, compatibility, metadata, allowed-tools, disable-model-invocation) and a command summary body. Best for small CLIs.GenSkillsDir(cmd, dir, config)— Generates a complete skill directory following the progressive disclosure convention:The main
SKILL.mdstays concise with linked references. Each reference file contains detailed docs for a single command (description, usage, examples, flags). Agents load only what they need, keeping context window usage minimal.Progressive disclosure in practice
SKILL.mdfrontmatter (~100 tokens) to decide relevancereferences/<cmd>.mdonly for the specific command it needsHow to use
Typical integration: add a
docsorskillssubcommand to your CLI, or call it from ago generatedirective.Design decisions
docpackage patterns — Same naming conventions (Gen*/Gen*Dir), same use ofprintOptions,byName,hasSeeAlso, same test and benchmark styleREFERENCE.md, each command gets its own file. This aligns with how agents work: they need detail on one command at a time, not the entire CLISkillsConfigkeeps the API clean and extensible as the agentskills.io spec evolves