coding-agent-extension-builder
Kotlin library for generating coding agent extensions with compile-time safety.
Why Use This Library
Writing extensions by hand is error-prone:
- Need to remember
marketplace.json format
- Need correct folder structure (
.claude-plugin/plugin.json, skills/*/SKILL.md)
- Easy to misspell field names (
allowed-tools? allowedTools?)
- Mistakes are hard to catch because agents still work with invalid config
Quick Start
// 1. Create a plugin
val plugin = Plugin.Builder(
name = "my-plugin",
description = "My plugin description",
version = "1.0.0"
)
.author(name = "Your Name")
.addCommand(
Command.Builder(
name = "my-command",
description = "What this command does",
body = "# Command\n\nInstructions..."
).build()
)
.addSkill(
Skill.Builder(
name = "my-skill",
description = "When to use this skill",
body = "# Skill\n\nGuidance..."
).build()
)
.build()
// 2. Create marketplace (optional)
val marketplace = Marketplace.Builder(
name = "my-marketplace",
owner = Owner(name = "Your Name")
)
.addPlugin(plugin)
.build()
// 3. Write to disk
marketplace.writeClaudeCodeExtension(Path("output"))
// Or just the plugin: plugin.writeClaudeCodeExtension(Path("output"))
Generated Structure
output/my-marketplace/
├── .claude-plugin/
│ └── marketplace.json
└── plugins/
└── my-plugin/
├── .claude-plugin/
│ └── plugin.json
├── commands/
│ └── my-command.md
└── skills/
└── my-skill/
└── SKILL.md
API Reference
Skill.Builder(name, description, body)
.license(license: String) - Set license
.allowedTools(vararg tools: String) - Restrict tools
.addMetadata(key, value) - Add custom metadata
Command.Builder(name, description, body)
- No optional fields currently
Plugin.Builder(name, description, version)
.author(name: String) - Set author
.addCommand(command: Command) - Add command
.addSkill(skill: Skill) - Add skill
.addHook(hook: HookMatcher) - Add hook
HookMatcher.Builder(event: HookEvent)
.matcher(pattern: String) - Tool pattern (e.g., "Write|Edit")
.command(command: String, timeout: Int?) - Add command hook
.prompt(prompt: String, timeout: Int?) - Add prompt hook (LLM-based)
HookEvent: PreToolUse, PostToolUse, PermissionRequest, Notification, UserPromptSubmit, Stop, SubagentStop, PreCompact, SessionStart, SessionEnd
Marketplace.Builder(name, owner)
.addPlugin(plugin: Plugin) - Add embedded plugin
.addPlugin(name, source, ...) - Add external plugin reference
.metadata(description, version, pluginRoot) - Set metadata
Run in Workspace
cd workspace
cp src/main/kotlin/Main.kt.template src/main/kotlin/Main.kt
# Edit Main.kt
./gradlew :workspace:run
1---2name: coding-agent-extension-builder3description: Generate Claude Code plugins, skills, and marketplaces using Kotlin DSL. Use when the user wants to: - Create a new plugin with commands and skills - Create a marketplace to distribute plugins - Generate correct folder structure (.claude-plugin/, skills/, commands/) - Avoid mistakes in JSON format and YAML front matter field names4license: MIT5---67# coding-agent-extension-builder89Kotlin library for generating coding agent extensions with compile-time safety.1011## Why Use This Library1213Writing extensions by hand is error-prone:14- Need to remember `marketplace.json` format15- Need correct folder structure (`.claude-plugin/plugin.json`, `skills/*/SKILL.md`)16- Easy to misspell field names (`allowed-tools`? `allowedTools`?)17- Mistakes are hard to catch because agents still work with invalid config1819## Quick Start2021```kotlin22// 1. Create a plugin23val plugin = Plugin.Builder(24 name = "my-plugin",25 description = "My plugin description",26 version = "1.0.0"27)28 .author(name = "Your Name")29 .addCommand(30 Command.Builder(31 name = "my-command",32 description = "What this command does",33 body = "# Command\n\nInstructions..."34 ).build()35 )36 .addSkill(37 Skill.Builder(38 name = "my-skill",39 description = "When to use this skill",40 body = "# Skill\n\nGuidance..."41 ).build()42 )43 .build()4445// 2. Create marketplace (optional)46val marketplace = Marketplace.Builder(47 name = "my-marketplace",48 owner = Owner(name = "Your Name")49)50 .addPlugin(plugin)51 .build()5253// 3. Write to disk54marketplace.writeClaudeCodeExtension(Path("output"))55// Or just the plugin: plugin.writeClaudeCodeExtension(Path("output"))56```5758## Generated Structure5960```61output/my-marketplace/62├── .claude-plugin/63│ └── marketplace.json64└── plugins/65 └── my-plugin/66 ├── .claude-plugin/67 │ └── plugin.json68 ├── commands/69 │ └── my-command.md70 └── skills/71 └── my-skill/72 └── SKILL.md73```7475## API Reference7677### Skill.Builder(name, description, body)78- `.license(license: String)` - Set license79- `.allowedTools(vararg tools: String)` - Restrict tools80- `.addMetadata(key, value)` - Add custom metadata8182### Command.Builder(name, description, body)83- No optional fields currently8485### Plugin.Builder(name, description, version)86- `.author(name: String)` - Set author87- `.addCommand(command: Command)` - Add command88- `.addSkill(skill: Skill)` - Add skill89- `.addHook(hook: HookMatcher)` - Add hook9091### HookMatcher.Builder(event: HookEvent)92- `.matcher(pattern: String)` - Tool pattern (e.g., "Write|Edit")93- `.command(command: String, timeout: Int?)` - Add command hook94- `.prompt(prompt: String, timeout: Int?)` - Add prompt hook (LLM-based)9596HookEvent: PreToolUse, PostToolUse, PermissionRequest, Notification, UserPromptSubmit, Stop, SubagentStop, PreCompact, SessionStart, SessionEnd9798### Marketplace.Builder(name, owner)99- `.addPlugin(plugin: Plugin)` - Add embedded plugin100- `.addPlugin(name, source, ...)` - Add external plugin reference101- `.metadata(description, version, pluginRoot)` - Set metadata102103## Run in Workspace104105```bash106cd workspace107cp src/main/kotlin/Main.kt.template src/main/kotlin/Main.kt108# Edit Main.kt109./gradlew :workspace:run110```