DEV Community

brian austin
brian austin

Posted on

Claude Code Routines are breaking my rate limits — here's how I fixed it

Claude Code Routines are breaking my rate limits — here's how I fixed it

Claude Code Routines just shipped and the HN thread has 347 points. Everyone is excited. I was too — until I realized routines make the rate limit problem dramatically worse.

What are Claude Code Routines?

Routines let you define multi-step workflows that Claude Code executes in sequence. Something like:

# .claude/routines/ship.md
Review all changed files for bugs
Run the test suite and fix any failures  
Update CHANGELOG.md with what changed
Write commit message and push
Enter fullscreen mode Exit fullscreen mode

Run it with: claude --routine ship

Sounds amazing. And it is — until you hit the wall.

The rate limit problem gets worse

Here's the math that nobody is talking about:

Single prompt session: ~8,000 tokens average
Routine with 4 steps: ~35,000 tokens average

That's 4x more token consumption per session. If you were hitting rate limits before, routines will get you there in one-quarter of the time.

I ran a routine on a medium-sized codebase (15 files changed) and burned through my entire daily quota in 90 minutes.

The symptoms

❌ Error: Rate limit exceeded
Retry after: 14400 seconds
Enter fullscreen mode Exit fullscreen mode

Four hours. Gone. In the middle of a ship routine.

What I tried first (that didn't work)

Splitting routines into smaller steps — still hits the same daily token limit, just more slowly

Caching — Claude Code's cache TTL is shorter than most people think, and Anthropic silently reduced it

Spreading across the day — helps but doesn't solve it for heavy days

What actually worked: API-direct access

The real fix is bypassing the Claude.ai rate limits entirely by calling the Anthropic API directly.

Here's a simple wrapper that runs your routine steps via API:

import anthropic
import re

client = anthropic.Anthropic(api_key="YOUR_KEY")

def run_routine(routine_file: str, context: str) -> None:
    with open(routine_file) as f:
        steps = [line.strip() for line in f if line.strip() and not line.startswith('#')]

    conversation = []

    for i, step in enumerate(steps, 1):
        print(f"\n🔄 Step {i}/{len(steps)}: {step}")

        conversation.append({
            "role": "user",
            "content": f"Context:\n{context}\n\nTask: {step}"
        })

        response = client.messages.create(
            model="claude-opus-4-5",
            max_tokens=8192,
            messages=conversation
        )

        result = response.content[0].text
        print(result)

        # Keep conversation going for context
        conversation.append({
            "role": "assistant",
            "content": result
        })

# Usage
run_routine(".claude/routines/ship.md", open("context.md").read())
Enter fullscreen mode Exit fullscreen mode

This runs at API rate limits, not the Claude.ai tier limits. No more 4-hour cooldowns.

The cost difference

Here's what's wild: running this via API is actually cheaper than the Claude.ai subscription if you're hitting rate limits regularly.

Claude.ai Pro: $20/month, rate-limited
Claude.ai Pro Max: $100/month, higher limits but still rate-limited
API direct: pay per token, no artificial daily limits

For most developers doing heavy routine work, the API costs $3-8/month in actual token spend.

But wait — you need an API key

This is where it gets annoying. Anthropic's API requires a credit card, approval process, and minimum $5 credit. It's not hard, but it's friction.

I built SimplyLouie as a $10/month developer tier that gives you:

  • Direct Claude API access
  • No approval process
  • No per-token billing surprises
  • Simple API key in your dashboard

Same endpoints, same models. Just $10/month flat.

Here's the curl:

curl https://simplylouie.com/api/chat \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [{"role": "user", "content": "Review these changed files for bugs"}],
    "model": "claude-opus-4-5"
  }'
Enter fullscreen mode Exit fullscreen mode

The GitHub Actions version

The real power move: run your routines in CI/CD where there are zero rate limits:

name: AI Code Review Routine
on: [pull_request]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Get changed files
        id: diff
        run: echo "files=$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT

      - name: Run Claude review routine
        run: |
          pip install anthropic
          python scripts/run_routine.py \
            --routine .claude/routines/review.md \
            --context "${{ steps.diff.outputs.files }}"
        env:
          ANTHROPIC_API_KEY: ${{ secrets.LOUIE_API_KEY }}
Enter fullscreen mode Exit fullscreen mode

Now every PR gets a full multi-step review routine, automatically, with no rate limits.

Conclusion

Claude Code Routines are genuinely powerful. The Anthropic team built something great here. But if you're using them seriously, you'll hit the wall fast.

The fix: API-direct access. Run your routines against the API and you get the same Claude intelligence with proper rate limits.

Happy shipping. 🚀


What routines are you building? Drop them in the comments — I'm collecting a library of useful ones.

Top comments (0)