Here's a fun one for the OpenClaw crowd: developer Shatil Khan figured out how to run Claude Code's authentication in headless mode and pipe it directly into an AI agent workflow—no API keys, no web accounts, just some creative symlink magic and systemd configuration.

The Problem: Tools Without Access

Khan's company had Claude Code installed in their dev environments but didn't provide web account access or API keys. No console.anthropic.com, no OAuth flow, nothing. Classic corporate IT lockout. But here's the thing—Claude Code carries its own authentication layer when you install it globally via npm install -g @anthropic-ai/claude-code, and that binary stores refresh tokens at ~/.claude/.credentials.json. Those tokens auto-refresh indefinitely as long as someone authenticated once interactively.

The Symlink Hack

The exploit is straightforward: Claude Code can run headlessly using the -p flag with --output-format=text. No ANTHROPIC_API_KEY environment variable required. Just pipe data into it and get back prose. Khan realized this meant Claude Code's CLI wasn't just an interactive coding assistant—it was a fully authenticated LLM engine sitting in their PATH, waiting to be exploited. The flow goes like this: install Claude Code globally, run claude /login once from any machine with web account access (even a personal laptop), and the OAuth refresh token gets stored locally. From that point forward, you can call echo "prompt here" | claude -p --output-format=text anywhere that binary exists, and Claude responds without asking for credentials again.

Making It Production-Ready

Of course, a hack that only works in your active shell session isn't worth much. Khan wrapped the setup as a systemd user service so it survives reboots and auto-restarts on crashes. The critical gotcha: systemd runs with a stripped-down environment that doesn't include your interactive shell's PATH. One line in the unit file—Environment=PATH=... pointing to wherever npm installed the claude symlink—is what makes or breaks the whole thing.

Meet the Clawfficer

What did they actually build with this? A Discord bot that acts as a product manager, dubbed "the Clawfficer." The bot pulls activity from all 8 of their GitHub repos across every branch (not just main), pipes everything into claude -p --output-format=text, and posts human-readable prose summaries to the #roadmap channel. Daily at 9 AM, weekly on Sundays at 10 AM. The summaries are actual sentences, not bullet points or JSON dumps. Khan describes one output as: "Medihelp saw 12 commits across 3 branches this week, mostly schema migrations by Mahim. The eyecraft landing page got its first PR review." The bot can also create GitHub issues and assign developers based on natural language commands in Discord.

Key Lessons From the Trenches

  • Branch coverage matters: GitHub's /commits endpoint defaults to the default branch, so iterate all branches and dedupe by commit SHA or your digest looks empty.
  • The OAuth token is everything: if ~/.claude/.credentials.json expires or corrupts, claude -p exits with code 1 and you fall back to bullet points. Run claude interactively once to re-auth.
  • systemd PATH ≠ shell PATH: this one-liner took "an embarrassing amount of time" to debug.

The Bottom Line

This is exactly the kind of creative workaround that corporate IT policies inadvertently encourage. Khan's team needed AI-powered workflow automation, procurement said no to API keys, and now they have a fully functional product manager bot running on OAuth tokens meant for interactive use. It's not officially supported—Anthropic doesn't endorse using Claude Code this way—but it works, and sometimes that's all the permission you need.