When your company gives you access to Claude Code but not actual Claude API keys or web accounts, you're left with a powerful CLI tool that can't log in the "normal" way. That's exactly the situation developer Shatil Khan found himself in—until he discovered how to hijack Claude Code's built-in OAuth authentication and pipe it directly into an OpenClaw-powered Discord bot.
The Symlink Hack
Claude Code installs as a global npm package and creates its own binary in your PATH. When you run claude /login, it opens a browser for OAuth with your Claude Pro/Max subscription and stores refresh tokens at ~/.claude/.credentials.json. Here's the critical part: Claude Code can run headlessly using echo "prompt" | claude -p --output-format=text with zero API key requirements. The CLI manages its own token refreshing automatically, meaning you get a fully authenticated LLM engine without ever touching ANTHROPIC_API_KEY or console.anthropic.com.
Building the Clawfficer
Khan wrapped this authentication pattern into a Discord bot he calls the "Clawfficer"—a product manager that lives in Slack. The bot aggregates GitHub activity across eight repositories, pulling commits from all branches (not just main), then pipes everything through claude -p --output-format=text for natural language summaries. It posts to #roadmap every morning at 9 AM and Sundays at 10 AM with prose like: "Medihelp saw 12 commits across 3 branches this week, mostly schema migrations by Mahim. The eyecraft landing page got its first PR review." Beyond passive updates, the Clawfficer can assign GitHub issues and tag Discord message URLs when developers flag problems.
Surviving Restarts with systemd
The trickier engineering challenge wasn't the AI integration—it was keeping the agent alive across reboots. Khan wrapped his setup as a systemd user service with one critical configuration: explicitly setting Environment=PATH=... in the unit file. Without this PATH override, systemd's stripped-down environment can't locate the Claude symlink and the whole workflow silently fails. "It's a one-line fix that took us an embarrassing amount of time to figure out," Khan admits.
Key Takeaways
- Claude Code stores OAuth tokens at ~/.claude/.credentials.json that auto-refresh indefinitely
- Headless mode via
claude -p --output-format=textprovides LLM access without API keys or web accounts - Branch coverage requires iterating all branches and deduping by commit SHA—GitHub's /commits endpoint defaults to main only
- systemd services need explicit PATH configuration since they run in a minimal environment stripped of shell variables
The Bottom Line
This isn't officially supported—you won't find this in Anthropic's documentation—but it works. Claude Code's CLI is fundamentally a headless LLM engine that happens to already be authenticated for your subscription. For internal tools that need to "just work" without procurement battles or IT approval, that's the real story here: sometimes the best API is one you weren't supposed to use.