picocli-command
Generate a Picocli @Command with subcommands, @Option/@Parameters, type converters, exit code constants, and unit tests.
- License 许可
- MIT
- 最近更新
- 2026-10-27
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- picocli-command
- model
- sonnet
- visibility
- public
- description
- Generate a Picocli @Command with subcommands, @Option/@Parameters, type converters, exit code constants, and unit tests.
- allowed-tools
- [ "Read", "Write", "Edit", "Bash", "Skill" ]
- context-budget
- light
- requires-capabilities
- [ "cli.picocli.framework" ]
03 SKILL.md 正文
Skill: Picocli Command Generator
Purpose
Generates a complete Picocli CLI command (or subcommand) following the hexagonal architecture pattern. Produces:
@Commandclass implementingCallable<Integer>@Optionand@Parametersdeclarations with type converters- Exit code constants
- Unit tests with
CommandLine.execute()assertions
Triggers
/picocli-command <CommandName> [--subcommand]— generate a top-level or subcommand/picocli-command <CommandName> --root— generate root command with standard options/picocli-command <CommandName> --crud— generate subcommands for create/list/delete operations
Parameters
| Parameter | Required | Description |
|---|---|---|
CommandName |
Yes | PascalCase command class name (e.g., GenerateCommand, ValidateCommand) |
--subcommand |
No | Generate as subcommand (registers with parent via subcommands =) |
--root |
No | Generate as root command with mixinStandardHelpOptions = true |
--crud |
No | Generate create/list/delete subcommands |
Workflow
Step 1 — Read Project Context
Read existing conventions:
knowledge/stack-patterns/picocli/index.md— Picocli patternsknowledge/layer-templates.md— Layer template patterns- Existing commands in
src/main/java/**/adapter/inbound/cli/for naming conventions
Step 2 — Generate Command Class
// src/main/java/{package}/adapter/inbound/cli/{CommandName}.java
@Command(
name = "{command-name}",
description = "{description}",
mixinStandardHelpOptions = true
)
public class {CommandName} implements Callable<Integer> {
@Option(names = {"-c", "--config"}, required = true,
description = "Config file path.")
private Path configFile;
private final {Port} port;
public {CommandName}({Port} port) {
this.port = port;
}
@Override
public Integer call() {
try {
// Delegate to application port
var result = port.execute(...);
System.out.printf("Success: %s%n", result);
return ExitCode.OK;
} catch (DomainException e) {
System.err.println("Error: " + e.getMessage());
return ExitCode.ERROR;
}
}
}
Step 3 — Generate Exit Codes (if not exists)
// src/main/java/{package}/adapter/inbound/cli/ExitCode.java
public final class ExitCode {
public static final int OK = 0;
public static final int ERROR = 1;
public static final int USAGE = 2;
private ExitCode() {}
}
Step 4 — Generate Tests
// src/test/java/{package}/adapter/inbound/cli/{CommandName}Test.java
class {CommandName}Test {
private final {Port} port = mock({Port}.class);
private final CommandLine cmd = new CommandLine(new {CommandName}(port));
@Test
void call_validInput_returnsZero() {
// Arrange
when(port.execute(any())).thenReturn(expectedResult);
// Act
int exitCode = cmd.execute("--config", "test.yaml");
// Assert
assertThat(exitCode).isEqualTo(ExitCode.OK);
}
@Test
void call_missingRequiredOption_returnsUsageError() {
int exitCode = cmd.execute();
assertThat(exitCode).isEqualTo(ExitCode.USAGE);
}
}
Output Checklist
- [ ] Command implements
Callable<Integer>(notRunnable) - [ ] Constructor injection of port (no static dependencies)
- [ ]
ExitCodeconstants used (not magic numbers) - [ ]
System.errfor errors,System.outfor success output - [ ]
mixinStandardHelpOptions = trueon root command - [ ] Tests use
CommandLine.execute()(not directcall()) - [ ] No
System.exit()inside command logic
Knowledge Pack References
knowledge/stack-patterns/picocli/index.md— Picocli patternsknowledge/layer-templates.md— Layer template patternsknowledge/architecture-hexagonal.md— Hexagonal architecture
04 同仓库更多 Skills
x-parallel-eval
Detects and classifies file-collision risks between work units (tasks, stories, or epic phases) before parallel execution. Reads ## File Footprint blocks produced by x-task-plan / x-story-plan, applies the parallelism-heuristics knowledge pack (hard / regen / soft categories + hotspot overrides), and emits a collision matrix + serialization recommendation in Markdown (default) or JSON.
parallelism-heuristics
Canonical catalog of file-collision heuristics for parallel task, story, and epic execution. Defines the File Footprint block format, the three Conflict Categories (hard / regen / soft), a hotspot list of high-contention paths, and the degrade-with-warning policy. Consumed by x-task-plan, x-story-plan, x-epic-map, x-parallel-eval, and x-dev-*-implement.
x-watch-pr-ci
Polls a PR's CI checks and Copilot review status, blocking until checks complete or timeout. Returns one of 8 stable exit codes (SUCCESS=0, CI_PENDING_PROCEED=10, CI_FAILED=20, TIMEOUT=30, PR_ALREADY_MERGED=40, NO_CI_CONFIGURED=50, PR_CLOSED=60, PR_NOT_FOUND=70). Writes a versioned state-file for session resume.
x-validate-docs
Documentation freshness gate: validates 6 dimensions (readme, api-specs, grpc-proto, adr, skill-docs, system-architecture) against code changes in a PR. Stack-aware — only validates targets declared/auto-detected from ProjectConfig.documentation.targets. Returns exit non-zero on staleness; produces structured report.
x-update-system-architecture
Incrementally updates docs/architecture/system.md after an epic completes. Appends new entries to the Decision Log (§11) using x-internal-write-report --append (dedup by ## ID: marker) and surgically inserts component/integration changes into sections 1-10 via Edit. Idempotent: re-running with the same epic produces a byte-identical system.md.
x-update-architecture
Incrementally updates the service architecture document with changes from architecture plans. Adds new components, integrations, flows, and ADR references without rewriting existing content. Use after implementation to keep architecture documentation current.