Skip to main content

create-subcommand

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

소스 정보

저장소
DataDog/datadog-agent
최근 소스 활동
2026년 7월 16일 18:42
감지된 SKILL.md 언어
영어
스타
3,769
포크
1,528

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
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
GitHub에서 보기