Documentation
¶
Overview ¶
Package generate produces static discovery files from structcli command trees.
All generators consume structcli.JSONSchema with jsonschema.WithFullTree and produce []byte output. The caller decides where to write the files.
The generators produce mechanically correct scaffolds — every flag name, type, default, env var, and required marker comes from the same struct definition that powers --jsonschema. Humans should add on top:
- Trigger phrases for skill discovery ("use when user asks to deploy")
- Workflow guidance and step-by-step instructions
- Realistic examples with domain-specific values
- Error handling advice and troubleshooting sections
- Negative triggers ("do NOT use for general file management")
Supported formats:
Index ¶
- func Agents(rootCmd *cobra.Command, opts AgentsOptions) ([]byte, error)
- func LLMsTxt(rootCmd *cobra.Command, opts LLMsTxtOptions) ([]byte, error)
- func Skill(rootCmd *cobra.Command, opts SkillOptions) ([]byte, error)
- func WriteAll(rootCmd *cobra.Command, outDir string, opts AllOptions) error
- type AgentsOptions
- type AllOptions
- type LLMsTxtOptions
- type SkillOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Agents ¶
func Agents(rootCmd *cobra.Command, opts AgentsOptions) ([]byte, error)
Agents generates an AGENTS.md file from a cobra command tree. Returns the file content as bytes.
func LLMsTxt ¶
func LLMsTxt(rootCmd *cobra.Command, opts LLMsTxtOptions) ([]byte, error)
LLMsTxt generates an llms.txt file from a cobra command tree. Returns the file content as bytes.
func Skill ¶
func Skill(rootCmd *cobra.Command, opts SkillOptions) ([]byte, error)
Skill generates a SKILL.md file from a cobra command tree. Returns the file content as bytes.
func WriteAll ¶ added in v0.14.0
func WriteAll(rootCmd *cobra.Command, outDir string, opts AllOptions) error
WriteAll generates SKILL.md, llms.txt, and AGENTS.md in outDir from the given command tree. It is the recommended entry point for //go:generate workflows.
When invoked from a //go:generate directive, outDir is typically os.Getwd since go generate sets the working directory to the package containing the directive.
Example:
func main() {
rootCmd, _ := mycli.NewRootCmd()
outDir, _ := os.Getwd()
if err := generate.WriteAll(rootCmd, outDir, generate.AllOptions{
ModulePath: "github.com/myuser/mycli",
Skill: generate.SkillOptions{Author: "myuser", Version: "1.0.0"},
}); err != nil {
log.Fatal(err)
}
}
Types ¶
type AgentsOptions ¶
type AgentsOptions struct {
ModulePath string // Go module path for install instructions (eg. "github.com/myorg/mycli")
IncludeMCP bool // Mention --mcp in Machine Interface section
}
AgentsOptions configures the AGENTS.md generator.
type AllOptions ¶ added in v0.14.0
type AllOptions struct {
// ModulePath is the Go module path of the CLI binary.
// It is used to derive the project URL for llms.txt and AGENTS.md.
// Example: "github.com/myuser/mycli"
ModulePath string
// Skill configures the SKILL.md generator (name override, author, version, mcp-server).
Skill SkillOptions
// IncludeMCP includes MCP server information in llms.txt and AGENTS.md (reserved for future use).
IncludeMCP bool
}
AllOptions configures all three generators together. It is the recommended configuration for WriteAll in //go:generate workflows.
type LLMsTxtOptions ¶
type LLMsTxtOptions struct {
ModulePath string // Go module path (eg. "github.com/myorg/mycli") — used to derive project URL
IncludeMCP bool // Mention --mcp in the output
}
LLMsTxtOptions configures the llms.txt generator.
type SkillOptions ¶
type SkillOptions struct {
Name string // Override skill name (default: root command name, kebab-case)
Author string // metadata.author (optional)
Version string // metadata.version (optional)
MCPServer string // metadata.mcp-server (optional)
}
SkillOptions configures the SKILL.md generator.