Skip to main content

How Custom CLI Tools Supercharge Claude Code and Opencode with Live Web Data

5 min readBy Hamza

Build a custom CLI tool that gives Claude Code and Opencode real-time access to Reddit, YouTube, Google, and any website — bridging the gap between AI and the live web.

CLI tool Claude CodeCLI tool OpencodeMCP CLIAI live web dataClaude Code custom toolOpencode custom toolAI assisted development

TLDR: I built a CLI tool called mycli because I wanted my AI coding assistant to do things it couldn't — browse live websites, search Reddit threads, fetch YouTube transcripts, search Google, manage my Gmail. I taught Claude Code how to use it using skill, Claude Code and Opencode can call these commands directly during a coding session and reason about the structured JSON output.


Why Build Your Own CLI Instead of Using MCP Servers?


I built my own because MCP servers are expensive on tokens and insecure. Every MCP server dumps its tool schemas into your context window — add five of them and you're burning thousands of tokens per request before even asking a question. A single CLI with one skill definition is drastically cheaper. And most MCP servers are random npm packages running as child processes with full system access — a malicious one can read your files or exfiltrate environment variables. Building your own means you control what runs on your machine.


To put numbers on it: a typical MCP server ships 10-30 tool definitions, each with descriptions, parameter schemas, and examples. That's roughly 500-1500 tokens per server just for the tool manifest. Connect 10 MCP servers and you're loading 5,000-15,000 tokens into every single API call before you've typed anything. My CLI registered as one skill definition? Around 500 tokens — and the AI only loads the commands it actually needs for the current task.


Is a Custom CLI Better Than Installing MCP Servers?


In my opinion, yes. The biggest advantage is I can add whatever tools I want and it's trivially easy for AI to use. Every command has proper --help docs, consistent flags, and structured JSON output. No AI has ever failed to use mycli — because good CLI documentation is all an AI needs to figure out a tool. It's a bridge between the AI's static training data and the live internet, without the bloat and risk of stacking third-party MCP servers.


The CLI I built — called mycli — is a TypeScript tool using Commander.js, chalk, and cli-table3. It's installed globally and handles several domains:


Web browsingmycli browse <url> fetches any page using a real browser connected via WebSocket and my custom extension. This bypasses anti-bot protections that simple HTTP clients can't handle. The command can even execute custom JavaScript on the page before extracting HTML, which means your AI assistant can interact with SPAs, dismiss cookie banners, or extract data from dynamically rendered content.


Reddit researchmycli reddit search <query> lets Claude Code or Opencode search Reddit for developer opinions mid-task. When evaluating libraries, debugging obscure errors, or understanding migration paths, real developer discussions beat documentation every time.


YouTube transcriptsmycli youtube fetch <video-id> pulls video transcripts using YouTube's innerTube API directly — no API key, no headless browser. Your AI can ingest a 45-minute tutorial's transcript in seconds and extract the relevant code patterns.


Google and social searchmycli google <query>, mycli linkedin <query>, and mycli twitter <query> give the AI live search across major platforms.


Gmail management — Full OAuth2-backed email operations from the terminal. AI can control it's own Gmail inbox now, it can send emails, clean up, extract information now.


How Does the AI Know How to Use mycli?


Every command in mycli has proper --help documentation with descriptions, flags, and examples. I also registered it as a skill in my Opencode configuration with a summary of available commands. When the AI needs live data — say, researching what developers think about a new framework — it runs mycli reddit search "framework-name" --format json directly. The results come back as structured JSON it can parse and reason about. No AI has ever failed to use it because good CLI docs are all an AI needs. The browse command is the most powerful one — it uses a real browser via WebSocket, bypassing anti-bot protections that block simple HTTP clients, and can even execute custom JavaScript on the page before extracting content.



Related: Claude Code Best Practices Related: Use an MCP Server in a JavaScript Script Related: Claude Code as an LLM API


Key Takeaways


  • AI coding assistants are limited to training data — a custom CLI bridges the gap to the live web
  • Third-party MCP servers pollute your context window with tool definitions and pose supply chain security risks — building your own avoids both
  • A single CLI skill (~500 tokens) vs 10 MCP servers (~5,000-15,000 tokens) — massive savings per API call
  • Good CLI documentation (--help, consistent flags, JSON output) is all an AI needs to use a tool — no AI has ever failed to use mycli
  • Use a real browser connection (WebSocket) for browsing commands to bypass anti-bot protections
  • YouTube transcript fetching via innerTube API requires no API key or headless browser
  • Commander.js + TypeScript is a solid stack — argument parsing, subcommands, and help generation come free