Add a new CLI subcommand to an agent binary (agent, cluster-agent, etc.)
62
55%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Optimize this skill with Tessl
npx tessl skill review --optimize ./.claude/skills/create-subcommand/SKILL.mdAdd a new CLI subcommand to a Datadog Agent binary. Each agent binary uses Cobra commands registered via a central subcommands.go file.
| Agent | Subcommands dir | Registration file |
|---|---|---|
| Core Agent | cmd/agent/subcommands/ | cmd/agent/subcommands/subcommands.go |
| Cluster Agent | cmd/cluster-agent/subcommands/ | cmd/cluster-agent/subcommands/subcommands.go |
| Process Agent | cmd/process-agent/subcommands/ | cmd/process-agent/subcommands/subcommands.go |
| Security Agent | cmd/security-agent/subcommands/ | cmd/security-agent/subcommands/subcommands.go |
| System Probe | cmd/system-probe/subcommands/ | cmd/system-probe/subcommands/subcommands.go |
| DogStatsD | cmd/dogstatsd/subcommands/ | cmd/dogstatsd/subcommands/subcommands.go |
Use AskUserQuestion to collect the following. If $ARGUMENTS provides values, skip those questions.
health, hostname, flareversion) or with config/IPC (fxutil.OneShot, e.g. hostname)?pkg/cli/subcommands/<name>/, No → cmd/<agent>/subcommands/<name>/Read the reference matching the chosen pattern, plus the target agent's registration file:
| Pattern | Reference file |
|---|---|
| Simple (no Fx) | cmd/agent/subcommands/version/command.go |
| With config/IPC | cmd/agent/subcommands/hostname/command.go |
| Shared across agents | pkg/cli/subcommands/health/command.go + cmd/agent/subcommands/health/command.go |
Also read the target agent's command/command.go for available GlobalParams fields.
Create cmd/<agent>/subcommands/<name>/command.go following the reference patterns exactly.
Edit the agent's subcommands.go: add an import with the cmd<Name> alias convention and add cmd<Name>.Commands to the factory slice. Follow the existing entries.
dda inv agent.build --build-exclude=systemd./bin/agent/agent <name> --helpdda inv linter.go/create-subcommand — Interactive: prompts for all details/create-subcommand agent my-command — Pre-fills agent and name0f36ad4
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.