agentleFS
goca-segoca-se/dotcontext/.claude/skills/add-cli-subcommand/SKILL.md

add-cli-subcommand

Skill9 starsChanged 4 months agoMITView on GitHub

Add a new subcommand to the dotcontext bash CLI (e.g. `dotcontext status`, `dotcontext validate`) — define the command function, route it via the case statement, and wire help and shell completion. Use when extending the CLI surface.

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this skill when you need to add a new subcommand to the dotcontext CLI (e.g., dotcontext status, dotcontext validate).

    line 12
  2. Very specific:

    Add a new function in the dotcontext script.

    line 23
  3. Very specific:

    Update the show_help() function:

    line 55
  4. Distinctive:

    Test your command on:

    line 115
  5. Very specific:

    Don't use bashisms: - Avoid [[ ]], $'...', arrays (use POSIX [ ], quoted strings)

    line 122
  6. Very specific:

    Don't hardcode paths: - Use variables like $CONTEXT_DIR

    line 123
  7. Distinctive:

    Don't skip error handling: - Check file existence, command success

    line 124
  8. Very specific:

    Don't output without color helpers: - Use print_* functions for consistency

    line 125

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: Add a New CLI Subcommand

When to Use

Use this skill when you need to add a new subcommand to the dotcontext CLI (e.g., dotcontext status, dotcontext validate).

Prerequisites

  • Understanding of bash scripting
  • Familiarity with the existing command structure in dotcontext

Steps

1. Define the command function

Add a new function in the dotcontext script. Follow the naming convention cmd_<name>:

cmd_status() {
    print_header "Status"

    # Command implementation here

    print_green "✓ Status check complete"
}

2. Add to the command router

Find the case statement in main() and add your command:

case "$1" in
    init)
        shift
        cmd_init "$@"
        ;;
    status)  # Add new case
        shift
        cmd_status "$@"
        ;;
    # ... other commands
esac

3. Add help text

Update the show_help() function:

show_help() {
    echo "Usage: dotcontext <command> [options]"
    echo ""
    echo "Commands:"
    echo "  init          Initialize context structure"
    echo "  status        Check context health"  # Add new line
    # ...
}

4. Handle arguments

Parse command-specific flags:

cmd_status() {
    local verbose=false

    while [ $# -gt 0 ]; do
        case "$1" in
            -v|--verbose)
                verbose=true
                shift
                ;;
            *)
                print_red "Unknown option: $1"
                exit 1
                ;;
        esac
    done

    # Use $verbose in implementation
}

5. Use helper functions

Leverage existing helpers for consistent output:

# Colors
print_green "Success message"
print_yellow "Warning message"
print_red "Error message"
print_blue "Info message"

# Prompts
if prompt_yes_no "Continue?"; then
    # User said yes
fi

# File operations
download_file "$url" "$dest"

6. Test on multiple platforms

Test your command on:

  • macOS (bash 3.2)
  • Linux (bash 5.x)
  • WSL (if applicable)

Anti-Patterns

  • Don't use bashisms - Avoid [[ ]], $'...', arrays (use POSIX [ ], quoted strings)
  • Don't hardcode paths - Use variables like $CONTEXT_DIR
  • Don't skip error handling - Check file existence, command success
  • Don't output without color helpers - Use print_* functions for consistency

Example

From the existing cmd_update function:

cmd_update() {
    local update_templates=false
    local force=false

    while [[ $# -gt 0 ]]; do
        case "$1" in
            --templates) update_templates=true; shift ;;
            --force) force=true; shift ;;
            *) shift ;;
        esac
    done

    if [ "$update_templates" = true ]; then
        cmd_update_templates "$force"
    else
        cmd_update_cli
    fi
}

Related

  • ADR-001: Single bash executable
  • Critical Rule: POSIX compatibility

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.