mcpbeat

Create Subcommand

datadog/create-subcommand

Add a new CLI subcommand to an agent binary (agent, cluster-agent, etc.)

679 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
3695
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/DataDog/datadog-agent --skill create-subcommand

What it tells the agent to use

found in the instruction text
Bash runs shell commands — read the instruction before connecting

The instruction itself

8 sections, as written by the author

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.

  • Target agent: Which agent binary? (Core Agent is most common)
  • Subcommand name: e.g. health, hostname, flare
  • Description: What does the subcommand do?
  • Complexity: Simple (no Fx, e.g. version) or with config/IPC (fxutil.OneShot, e.g. hostname)?
  • 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

  • Build: dda inv agent.build --build-exclude=systemd
  • Test: ./bin/agent/agent <name> --help
  • Lint: dda inv linter.go

Usage

  • /create-subcommand — Interactive: prompts for all details
  • /create-subcommand agent my-command — Pre-fills agent and name

How to use it

Copy the folder

Take datadog/create-subcommand from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.