cd /news/developer-tools/hack-claude-p · home topics developer-tools article
[ARTICLE · art-99624] src=laughingmeme.org ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Hack: claude -p

A developer shares a quick hack using the `claude -p` command-line tool to call Anthropic's Claude API without separate key management, leveraging the existing authenticated Claude environment. The script, which classifies GitHub pull requests, uses a subprocess call to `claude -p` with a prompt and returns JSON output, simplifying LLM integration in work contexts.

read1 min views12 publishedAug 17, 2026

claude -p

is a quick hack that I find myself using more.

Calling one of the various LLM APIs is easy. But requires key management. For me on a personal project that’s no big deal. In a work context it’s less trivial. But I’m working in claude

, which means I have a tool talking to a LLM API running already all the time, that already has not only an API key, but also an allocated budget that is being managed around making me more productive. Much easier if all my LLM based productivity is spend hits a single line item.

E.g. a quick script to classify Github PRs has a section like:

  return f"""You are classifying GitHub pull requests for an engineering team.

  PRODUCT AREAS (choose exactly one per PR):
  {area_lines}

  WORK TYPES (choose exactly one per PR):
  {work_type_lines}

  For each PR, return a JSON array with these fields:
  - pr_id, product_area, work_type, confidence, keywords

  Return ONLY the JSON array. No prose, no markdown fences.

  PULL REQUESTS:
  {prs_text}"""

And the call itself:

  def _call_claude(prompt: str) -> str | None:
      try:
          result = subprocess.run(
              ['claude', '-p', '--output-format', 'text'],
              input=prompt,
              capture_output=True,
              text=True,
              timeout=300,
          )
          return result.stdout.strip() if result.returncode == 0 else None
      except (subprocess.TimeoutExpired, FileNotFoundError):
          return None

Probably this is what the agent sdk is for? This worked.

── more in #developer-tools 4 stories · sorted by recency
── more on @anthropic 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/hack-claude-p] indexed:0 read:1min 2026-08-17 ·