250-cli

A ruleset for building command-line programs, which are tools operated from a terminal. It covers clear errors, debug modes, secret handling, input checks, and platform conventions.

In plain words
What is it for?
Use it when designing or reviewing terminal commands, flags, logging, validation, error handling, and debug behavior.
Why use it?
It helps command-line tools behave predictably and makes failures easier to investigate without exposing sensitive information.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/d-padmanabhan/agent-engineering-handbook/250-cli
Clone the repo
git clone --depth 1 https://github.com/d-padmanabhan/agent-engineering-handbook
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,956 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00012 $0.01956
Opus 5 $0.00006 $0.00978
Sonnet 5 $0.00002 $0.00391
Haiku 4.5 $0.00001 $0.00196

Measured 2d ago against content hash b9917886fcac, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

250-cli scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

subprocess.run(command, shell=True)
rules/250-cli.mdc · 384 lines

How it starts

The opening of the file, as written. The whole thing — 384 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLI Application Engineering Ruleset

Goal: Build secure, user-friendly, debuggable command-line interfaces that follow platform conventions.

Core Principles

  • User Experience First: Clear error messages, helpful usage, intuitive flags
  • Debuggability: Always provide debug mode for troubleshooting
  • Security: Never log secrets, validate inputs, fail fast
  • Platform Conventions: Follow platform-specific CLI patterns

Debug Mode Patterns

Environment Variable Pattern

# Enable debug mode
DEBUG=1 my-cli command

# Or with specific namespaces
DEBUG=my-cli:* my-cli command

Command-Line Flag Pattern

# Enable debug mode
my-cli --debug command

# Verbose mode (different from debug)
my-cli --verbose command

# Quiet mode
my-cli --quiet command

Implementation Examples

Python
import os
import logging
import sys

# Setup logging
log_level = logging.INFO
if os.getenv("DEBUG") == "1" or "--debug" in sys.argv:
    log_level = logging.DEBUG

logging.basicConfig(
    level=log_level,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

def main():
    logger.debug("Debug mode enabled")
    # ... rest of CLI logic
Node.js / JavaScript

Use the debug library:

import debug from 'debug';

// Enable debug via environment variable
// DEBUG=1 npm start
// DEBUG=my-cli:* npm start
// DEBUG=my-cli:auth npm start

const debugLog = debug('my-cli:main');
const authDebug = debug('my-cli:auth');

function main() {
  debugLog('Starting CLI application');
  authDebug('Authenticating user');
  // ... rest of CLI logic
}

// Enable debug output
if (process.env.DEBUG || process.env.AI_DEBUG_ENABLE === "1") {
  debug.enabled = true;
}
Go
package main

import (
    "flag"
    "log"
    "os"
)

var (
    debugFlag = flag.Bool("debug", false, "Enable debug logging")
    verboseFlag = flag.Bool("verbose", false, "Enable verbose output")
)

func main() {
    flag.Parse()

    // Check environment variable
    debugMode := *debugFlag || os.Getenv("DEBUG") == "1"

    if debugMode {
        log.SetFlags(log.LstdFlags | log.Lshortfile)
        log.SetOutput(os.Stderr)
    }

    log.Printf("Debug mode: %v", debugMode)
    // ... rest of CLI logic
}

Read the full file on GitHub · 384 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 384 lines · 12 tokens per session scan A b9917886fcac

Subscribe to this mod's changes

250-cli is a cursor rule published in the GitHub repository d-padmanabhan/agent-engineering-handbook (15 stars, last pushed 2d ago), licensed MIT. It adds 12 tokens to every session and 1,956 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.