Philosophy
Browser Debugger CLI is designed as an agent-first tool where information density and predictability take precedence over human ergonomics. Every design decision asks: “Does this help an agent make decisions?”Core Principles
These principles are extracted fromdocs/principles/AGENT_FRIENDLY_TOOLS.md and implemented throughout the codebase.
1. Self-Documenting Tools
Agents don’t read documentation - they query capabilities.Introspection Commands
All capabilities are discoverable programmatically (CLAUDE.md:10):
Help as Structured Data
src/commands/shared/CommandRunner.ts:24
2. Semantic Exit Codes
Exit codes communicate actionable information, not just success/failure.Exit Code Ranges
Based on Square’s semantic exit code system (docs/principles/AGENT_FRIENDLY_TOOLS.md:66):
Specific Exit Codes
Fromsrc/utils/exitCodes.ts:35:
| Code | Name | Meaning | Agent Action |
|---|---|---|---|
0 | SUCCESS | Operation completed | Proceed to next step |
81 | INVALID_ARGUMENTS | Bad input/flags | Fix arguments, don’t retry |
83 | RESOURCE_NOT_FOUND | Resource missing | Verify resource exists |
87 | STALE_CACHE | Cache invalidated | Re-run query to refresh |
102 | CDP_TIMEOUT | Browser unresponsive | Retry with backoff |
110 | SOFTWARE_ERROR | Internal bug | Report bug, don’t retry |
Agent Decision Logic
src/utils/exitCodes.ts:4):
Exit codes are part of bdg’s stable public API. Values will not change in minor versions.
3. Structured JSON Output
All commands support--json for machine-readable output.
JSON Output Envelope
Consistent response structure across all commands (CLAUDE.md:90):
Real Example
src/commands/shared/CommandRunner.ts:24
4. Structured Error Messages
Errors include recovery suggestions.Error Structure
Real Examples
Resource not found (CLAUDE.md:44):
CLAUDE.md:110):
CLAUDE.md:126):
5. Predictable Output Format
Same input always produces same output structure.Versioned Schemas
All JSON output includes version number for schema tracking:Additive Changes Only
Fromdocs/principles/AGENT_FRIENDLY_TOOLS.md:50:
- ✅ Adding new fields: Safe (minor version bump)
- ✅ Adding new commands: Safe (minor version bump)
- ❌ Removing fields: Breaking change (major version bump)
- ❌ Changing field types: Breaking change (major version bump)
Stream Separation
Primary data →stdout (parseable):
stderr (ignorable):
console.error() for logs and stdout for data.
6. Context Without Verbosity
Structured information, not chatty narration.Bad Example (Verbose)
Good Example (Structured)
Best Example (JSON)
7. Zero-Based Indexing
All indices are 0-based everywhere for consistency. FromCLAUDE.md:140:
src/commands/dom/query.ts, src/commands/dom/get.ts
8. Composable Commands
Each command does one thing and composes via pipes.Unix Pipeline Patterns
Command Independence
Fromdocs/principles/AGENT_FRIENDLY_TOOLS.md:281:
- ✅ One responsibility: Each command answers one specific question
- ✅ Stable output: Line-based or JSON format
- ✅ Clean stdout: No progress bars or decorations
- ✅ Composable: Output feeds into next command
9. Non-Interactive Execution
No prompts or interactive flows. All commands work without stdin:10. Case-Insensitive Input
Flexible input parsing reduces errors. CDP methods are case-insensitive (src/commands/cdp.ts:105):
Real-World Usage Examples
Example 1: Check for Console Errors
Example 2: Monitor Network Failures
Example 3: Extract All Links
Design Checklist
Fromdocs/principles/AGENT_FRIENDLY_TOOLS.md:476:
✅ Command Design
- Each command answers one specific question
- Subcommands reflect logical navigation path
- Command names are verbs or nouns, never sentences
- All commands support
--jsonflag - All commands support non-interactive execution
✅ Output Design
- Primary data goes to stdout
- Logs/progress go to stderr
- Default output is human-readable AND line-parseable
- JSON output has stable schema with version number
- No ANSI colors when stdout is not a TTY
✅ Error Handling
- Exit codes follow semantic ranges (0, 80-99, 100-119)
- Errors include
type,code,suggestion - Error messages on stderr
- JSON errors when
--jsonflag used - No retry logic (let agents decide)
✅ Composability
- Commands can be piped together
- Output can be filtered with grep/awk/jq
- Each command has single responsibility
References
These design principles are based on:-
InfoQ Article: “Keep the Terminal Relevant: Patterns for AI Agent Driven CLIs” (August 2025)
- Machine-friendly escape hatches
- Output as API contracts
-
Square Engineering: “Command Line Observability with Semantic Exit Codes” (January 2023)
- Exit code ranges: 80-99 user errors, 100-119 software errors
-
Command Line Interface Guidelines (clig.dev)
- Unix philosophy application
- Output separation (stdout/stderr)
-
Unix Philosophy (Bell Labs, 1978)
- Do one thing well
- Composability through pipes
Version stability: Exit codes and JSON schemas are part of bdg’s stable API. Changes follow semantic versioning.
Related Topics
- Sessions - Daemon architecture and lifecycle
- CDP Access - Self-documenting CDP introspection
- CLI Reference - Complete command documentation

