create-subcommand
DataDog/datadog-agent/.agents/skills/create-subcommand/SKILL.md
Add a new CLI subcommand to an agent binary (agent, cluster-agent, etc.)
Skill3.8k starsChanged 2 days ago
What's in it
- Agent Binaries
- Instructions
- Step 1: Gather information from the user
- Step 2: Read reference examples
- Step 3: Create the subcommand
- Step 4: Register
- Step 5: Verify
- Usage
Tools it asks for
- Bash
- Read
- Write
- Edit
- Glob
- Grep
- AskUserQuestion
--- name: create-subcommand description: Add a new CLI subcommand to an agent binary (agent, cluster-agent, etc.) allowed-tools: Bash, Read, Write, Edit, Glob, Grep, AskUserQuestion argument-hint: "[agent] [subcommand-name]" model: sonnet --- Add a new CLI subcommand to a Datadog Agent binary. Each agent binary uses Cobra commands registered via a central `subcommands.go` file. ## Agent Binaries | 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` | ## Instructions ### Step 1: Gather information from the user Use `AskUserQuestion` to collect the following. If `$ARGUMENTS` provides values, skip those questions. 1. **Target agent**: Which agent binary? (Core Agent is most common) 2. **Subcommand name**: e.g. `health`, `hostname`, `flare` 3. **Description**: What does the subcommand do? 4. **Complexity**: Simple (no Fx, e.g. `version`) or with config/IPC (`fxutil.OneShot`, e.g. `hostname`)? 5. **Shared across agents?**: Yes → `pkg/cli/subcommands/<name>/`, No → `cmd/<agent>/subcommands/<name>/` ### Step 2: Read reference examples 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. ### Step 3: Create the subcommand Create `cmd/<agent>/subcommands/<name>/command.go` following the reference patterns exactly. ### Step 4: Register 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. ### Step 5: Verify 1. Build: `dda inv agent.build --build-exclude=systemd` 2. Test: `./bin/agent/agent <name> --help` 3. Lint: `dda inv linter.go` ## Usage - `/create-subcommand` — Interactive: prompts for all details - `/create-subcommand agent my-command` — Pre-fills agent and name
More agent context in DataDog/datadog-agent
42 other files this repository gives its agents.
CLAUDE.md
Cursor rule
Skill
- agent-supply-chain-newsletter.agents/skills/agent-supply-chain-newsletter/SKILL.md
- allium.agents/skills/allium/SKILL.md
- auto-jira.agents/skills/auto-jira/SKILL.md
- create-component.agents/skills/create-component/SKILL.md
- create-config-field.agents/skills/create-config-field/SKILL.md
- create-core-check.agents/skills/create-core-check/SKILL.md
- create-epic-recap.agents/skills/create-epic-recap/SKILL.md
- create-go-module.agents/skills/create-go-module/SKILL.md
- create-invoke-task.agents/skills/create-invoke-task/SKILL.md
- create-pr.agents/skills/create-pr/SKILL.md
- create-release-note.agents/skills/create-release-note/SKILL.md
- create-runtime-setting.agents/skills/create-runtime-setting/SKILL.md
- create-status-provider.agents/skills/create-status-provider/SKILL.md
- cws-btfhub-sync.agents/skills/cws-btfhub-sync/SKILL.md
- cws-iouring-coverage.agents/skills/cws-iouring-coverage/SKILL.md
- e2e-audit.agents/skills/e2e-audit/SKILL.md
- explain-lading-config.agents/skills/explain-lading-config/SKILL.md
- follow-pr.agents/skills/follow-pr/SKILL.md
- gpu-live-metric-validation.agents/skills/gpu-live-metric-validation/SKILL.md
- handle-pr-ci-failure.agents/skills/handle-pr-ci-failure/SKILL.md
- injector-dev.agents/skills/injector-dev/SKILL.md
- locate-config-setting.agents/skills/locate-config-setting/SKILL.md
- quality-gate-size-analysis.agents/skills/quality-gate-size-analysis/SKILL.md
- review-pr-comments.agents/skills/review-pr-comments/SKILL.md
- run-e2e.agents/skills/run-e2e/SKILL.md
- run-jira.agents/skills/run-jira/SKILL.md
- run-windows-e2e.agents/skills/run-windows-e2e/SKILL.md
- triage-ci-failure.agents/skills/triage-ci-failure/SKILL.md
- update-3rd-party-libs.agents/skills/update-3rd-party-libs/SKILL.md
- update-otel-deps.agents/skills/update-otel-deps/SKILL.md
- write-e2e.agents/skills/write-e2e/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
Reports can't be read right now.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool registry_write, action report. How to connect one.

