Agent Skillsldayton/Dippy › add-command

add-command

GitHub

用于为CLI工具添加新命令支持,指导如何研究命令行为、决定安全策略(白名单或Handler)、编写测试及实现分类逻辑。

.claude/skills/add-command/SKILL.md ldayton/Dippy

Trigger Scenarios

需要新增CLI命令支持 实现新的CLI处理器 配置命令安全分类

Install

npx skills add ldayton/Dippy --skill add-command -g -y
More Options

Non-standard path

npx skills add https://github.com/ldayton/Dippy/tree/main/.claude/skills/add-command -g -y

Use without installing

npx skills use ldayton/Dippy@add-command

指定 Agent (Claude Code)

npx skills add ldayton/Dippy --skill add-command -a claude-code -g -y

安装 repo 全部 skill

npx skills add ldayton/Dippy --all -g -y

预览 repo 内 skill

npx skills add ldayton/Dippy --list

SKILL.md

Frontmatter
{
    "name": "add-command",
    "description": "Add support for a new CLI command. Use when implementing a handler or adding to SIMPLE_SAFE.",
    "argument-hint": "<command>",
    "disable-model-invocation": true
}

Add support for $ARGUMENTS in Dippy.

1. Research

tldr pages:

ls ~/source/tldr/pages/*/$ARGUMENTS*.md
cat ~/source/tldr/pages/*/$ARGUMENTS.md

CLI docs:

$ARGUMENTS --help
man $ARGUMENTS

Note which operations are read-only vs mutations.

2. Decide: Handler or SIMPLE_SAFE?

  • SIMPLE_SAFE: Always safe regardless of arguments (read-only, no destructive flags). Go to step 3A.
  • Handler: Needs subcommand/flag analysis. Go to step 3B.

3A. SIMPLE_SAFE Path

Add to SIMPLE_SAFE in src/dippy/core/allowlists.py and add tests to tests/test_simple.py in the appropriate category. Skip to step 5.

3B. Handler Path

Create tests/cli/test_$ARGUMENTS.py:

"""Test cases for $ARGUMENTS."""

import pytest
from conftest import is_approved, needs_confirmation

TESTS = [
    # Safe operations
    ("$ARGUMENTS <safe-subcommand>", True),
    ("$ARGUMENTS --help", True),
    # Unsafe operations
    ("$ARGUMENTS <unsafe-subcommand>", False),
]

@pytest.mark.parametrize("command,expected", TESTS)
def test_command(check, command: str, expected: bool):
    result = check(command)
    if expected:
        assert is_approved(result), f"Expected approve: {command}"
    else:
        assert needs_confirmation(result), f"Expected confirm: {command}"

4. Implement Handler

Create src/dippy/cli/$ARGUMENTS.py:

"""$ARGUMENTS handler for Dippy."""

from dippy.cli import Classification, HandlerContext

COMMANDS = ["$ARGUMENTS"]

SAFE_ACTIONS = frozenset({"list", "show", "status"})

def classify(ctx: HandlerContext) -> Classification:
    tokens = ctx.tokens
    action = tokens[1] if len(tokens) > 1 else None
    if action in SAFE_ACTIONS:
        return Classification("allow", description=f"$ARGUMENTS {action}")
    return Classification("ask", description="$ARGUMENTS")

For handler patterns (nested subcommands, flag-checking, delegation), see patterns.md.

5. Iterate

just test

Fix failures until tests pass.

6. Verify

just check MUST pass before you're done.

Version History

  • 2edad4a Current 2026-07-24 21:07

Same Skill Collection

.claude/skills/check-coverage/SKILL.md
.claude/skills/release/SKILL.md
.claude/skills/verify-counts/SKILL.md
.claude/skills/debug/SKILL.md

Metadata

Files
0
Version
2edad4a
Hash
882731a0
Indexed
2026-07-24 21:07

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 23:53
浙ICP备14020137号-1 $Гость$