cli-development

Instructions for developing the command-line interface of the Bazel-first iOS tool, including subcommands, argument parsing, streaming output, and help text.

In plain words
What is it for?
Use it when adding or changing CLI commands, flags, parsers, streaming build or test output, structured results, or files under src/cli/.
Why use it?
It keeps new CLI work consistent, especially when commands pass results between the command line and the MCP server.

Skill for Claude CodeCodex

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 skills/debugswift/xcodebazelmcp/cli-development
Any agent
npx skills add DebugSwift/XcodeBazelMCP --skill cli-development
Clone the repo
git clone --depth 1 https://github.com/DebugSwift/XcodeBazelMCP

Made for: Claude Code, Codex.

Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 556 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00034 $0.00556
Opus 5 $0.00017 $0.00278
Sonnet 5 $0.00007 $0.00111
Haiku 4.5 $0.00003 $0.00056

Measured yesterday against content hash 921b89e50888, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cli-development scanned grade A with 0 findings 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 yesterday.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/cli-development/SKILL.md · 45 lines

What it actually says

CLI Development

Conventions

  • Positional arg is the target/path/bundleId. Flags use --kebab-case.
  • Repeatable flags (--arg, --config, --launch-arg, --startup-arg) accumulate into arrays via append() helper.
  • printTool is the universal CLI→MCP bridge: calls callBazelTool, prints text content, sets process.exitCode on error.
  • ToolContent is a union type ({ type: 'text'; text } | { type: 'resource'; ... }). Use extractText() helper to safely map to .text.

File Layout

File Responsibility
src/cli.ts Thin dispatcher (~400 lines)
src/cli/parsers.ts 48 parse functions (~730 lines)
src/cli/commands.ts runUpgrade, runDaemon, etc. (~240 lines)
src/cli/help.ts printHelp (~160 lines)

Streaming

  • --stream flag on build/test/clean/query uses callBazelToolStreaming which pipes chunks directly to process.stdout.write.
  • MCP streaming uses notifications/progress with progressToken from the client's _meta.
  • Structured output: toolResult() returns both content (human-readable) and structuredContent (machine-parseable JSON with exitCode, command, output, target).

Log Streaming

  • log-start in CLI mode streams directly to stdout via spawn('xcrun', [...], { stdio: ['ignore', 'inherit', 'inherit'] }) — stops on Ctrl+C.
  • The MCP log_capture_start/log_capture_stop pair uses in-memory capture (server stays alive between calls).
  • sim-appearance accepts both --appearance dark flag and dark as a positional arg.

Session Defaults

  • Session defaults are in-memory per process — don't persist across CLI invocations (each node dist/cli.js is a new process).
  • In MCP server mode, they persist for the session.
  • Profiles loaded from config.yaml under profiles: key. activateProfile merges profile defaults into session defaults.
  • loadConfigFile() is lazy — called only once via a configLoaded guard.
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. yesterday First seen · 45 lines · 34 tokens per session scan A 921b89e50888

Subscribe to this mod's changes

cli-development is a skill published in the GitHub repository DebugSwift/XcodeBazelMCP (7 stars, last pushed 1mo ago), licensed MIT. It adds 34 tokens to every session and 556 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.