Claude Code Just Became Your CLI's Brain (And It's Unhinged How Well This Works)

Okay so I've been messing around with this pattern and it's lowkey revolutionary. The setup is almost too simple: build a CLI that does one thing, write a skill file that teaches Claude how to use it, profit.

I stumbled into this building an Android QA agent — you describe a test in plain English and Claude executes it on a device, recording everything for replay. But the pattern? General purpose. Works for literally any CLI.

The Core Pattern: Let Claude Drive

Your CLI doesn't need to be smart. It just needs flags and functionality. The intelligence lives in a markdown file — a "skill" — that tells Claude how to map human language to CLI invocations.

The user never thinks about flags. They describe what they want. Claude reads the skill, figures out the flags, executes. Done.

Prompt-Driven Features (No Docs Required)

This is where it gets based. Instead of making users read documentation, you teach Claude to detect intent and activate features automatically.

The skill file is just markdown:

Check the user's prompt for: "track performance", "frame rate", "fps", "rendering".

If any match, add --perf to the command.

That's it. User says "measure performance while scrolling" and the right flags get passed. No syntax to memorize. No --help to read.

You can stack these. "Track performance and enable tracing" activates two features from one sentence. Each feature has its keyword list. Claude composes them naturally.

The CLI stays mechanical — it accepts --perf and --trace, writes config to a lock file. The skill layer is what makes it feel conversational.

Human-in-the-Loop Done Right

Claude Code's AskUserQuestion tool lets you build programs that pause for real ambiguity and continue autonomously otherwise.

Example: my tool needs to know which Android device to target. One device connected? It picks it. Multiple devices? Shows a dropdown. The tool stays autonomous by default, defers exactly when it should.

This pattern works everywhere: deploy targets, database selection, branch picking. Autonomous until it genuinely isn't.

Session Lifecycle: Skills Start, Hooks Guarantee Stop

Useful pattern for anything with setup/teardown: skill starts the process, Claude Code hook guarantees cleanup.

The skill tells Claude to call a start script. That script creates a lock file tracking session state. When Claude finishes, stop script reads lock file, does teardown, cleans up.

But what if user hits Ctrl+C? Or Claude forgets? The Stop hook in .claude/settings.json catches it.

The lock file is both a mutex (prevents overlapping sessions) and a state store (tells stop script what to clean up). If Claude already stopped gracefully, lock file is gone, hook is no-op.

Works for recording sessions, server processes, temp resources — anything with lifecycle.

Building the Tool From Within (This Part Is Wild)

I build this tool from the same Claude Code session I use to run it. Claude distinguishes between "run this test" and "add this feature to the stop script."

Development loop is tight. Run tool, notice something missing, say "add support for memory stats at session end." Claude reads existing code, understands patterns, implements feature.

I haven't manually written any skill files. Claude generates them as a byproduct of iteration. You describe behavior, Claude implements the script, then writes the skill that teaches itself how to use it.

Self-reinforcing cycle, ngl.

The Recipe

  1. Build a simple CLI — flags, single purpose, no complexity
  2. Write a skill — maps keywords to flags in markdown
  3. Use AskUserQuestion — for genuine ambiguities only
  4. Add a hook — lifecycle guarantees (cleanup, finalization)
  5. Iterate from within — let Claude build next feature while using current one

Ship It

Think about manual processes that could be automated. Pulling Jira data, deployment checklists, mobile QA, accessibility audits — anything with repeatable steps.

Build the CLI first. Keep it simple. Then let Claude use it. Skills emerge from real usage. The tool evolves naturally when your primary user can reason about what it does.

Project is open source: github.com/tobrun/android-qa-agent


Related: Claude Code tutorial GitHub, Claude Code beginner guides, Claude Code demo, Claude Code video tutorials, Claude Code VSCode setup, YouTube Claude Code training

T
Written by TheVibeish Editorial