Skip to main content

One post tagged with "github-integration"

View All Tags

· 9 min read
Arkin Eliezer Julijanto

Meta Description: Claude Code Routines let you automate repetitive development tasks with scheduled jobs, API triggers, and GitHub webhooks. Here's how to build autonomous coding workflows that run 24/7.

Beyond Chat: When Your AI Agent Needs to Run on Autopilot​

Chat-based AI coding has transformed how developers work. But there's a limit to what you can do through conversational prompts alone. Sometimes you need work to happen while you're asleep — or while you're focused on something else entirely.

That's what Claude Code Routines are for: pre-configured Claude Code sessions that run automatically, triggered by schedules, API calls, or GitHub events. They execute on Anthropic-managed cloud infrastructure, so they keep working when your laptop is closed.

The release of Routines signals a broader shift in AI-assisted development: moving from interactive assistance to agentic automation. Instead of asking Claude to do something, you configure Claude to do it repeatedly, on its own schedule, without human intervention.

What Are Claude Code Routines?​

A Routine is a saved Claude Code configuration that includes:

  • A prompt defining the task
  • One or more GitHub repositories to work in
  • A set of MCP connectors for external services
  • One or more triggers that start the routine

When a trigger fires, Claude spins up a new cloud session, executes the prompt against the specified repositories, and creates a session record you can review later. It's like saving a perfect coding prompt and having Claude run it for you whenever you need.

Three Trigger Types​

Scheduled: Run on a recurring cadence — hourly, daily, weekdays, weekly, or custom cron intervals. Perfect for periodic maintenance tasks.

API: Trigger on demand with an HTTP POST to a dedicated endpoint. Use this to wire Claude Code into alerting systems, deploy pipelines, or internal tools.

GitHub: React to repository events like pull requests, pushes, or releases. Enables automated code reviews, PR triage, or synchronized library updates.

Key Capabilities​

  • Runs autonomously with no approval prompts
  • Can execute shell commands and use skills committed to repositories
  • Connects to external services via MCP (Slack, Linear, Google Drive, etc.)
  • Creates claude/-prefixed branches for its changes
  • Each run creates a session you can review or continue manually

What Can You Automate with Routines?​

The use cases are still emerging, but the documentation highlights several compelling patterns:

Backlog Maintenance​

A schedule trigger runs every weeknight, reading issues opened since the last run, applying labels based on the area of code, assigning owners, and posting a summary to Slack. Your team starts the day with a groomed queue instead of a messy backlog.

Alert Triage​

Your monitoring tool calls the routine's API endpoint when an error threshold is crossed. The routine pulls the stack trace, correlates it with recent commits, and opens a draft PR with a proposed fix. On-call reviews the PR instead of starting from a blank terminal.

Bespoke Code Review​

A GitHub trigger runs on pull_request.opened. The routine applies your team's own review checklist, leaves inline comments for security, performance, and style issues, and adds a summary comment so human reviewers can focus on design instead of mechanical checks.

Deploy Verification​

Your CD pipeline calls the routine's API endpoint after each production deploy. The routine runs smoke checks, scans error logs for regressions, and posts a go/no-go to your release channel before the deploy window closes.

Documentation Drift Detection​

A schedule trigger runs weekly, scanning merged PRs since the last run, flagging documentation that references changed APIs, and opening update PRs against the docs repository.

Cross-Language Library Ports​

A GitHub trigger runs on merged PRs in one SDK repository, ports the change to a parallel SDK in another language, and opens a matching PR — keeping multiple language implementations in sync without human re-implementation.

These patterns have something in common: they're unattended, repeatable, and tied to a clear outcome. That's the sweet spot for Routines.

How to Create a Routine​

From the Web Interface​

  1. Visit claude.ai/code/routines and click New routine
  2. Name the routine and write the prompt — this is the most important part. The routine runs autonomously, so the prompt must be self-contained and explicit about what to do and what success looks like
  3. Select one or more GitHub repositories. Claude clones them from the default branch and creates claude/-prefixed branches for changes
  4. Pick a cloud environment that controls network access, environment variables, and setup scripts
  5. Configure triggers — you can combine schedule, API, and GitHub triggers on a single routine
  6. Review connectors — remove any MCP connectors the routine doesn't need
  7. Click Create. The routine runs the next time a trigger matches

From the CLI​

Run /schedule in any session to create a scheduled routine conversationally. You can also pass a description directly: /schedule daily PR review at 9am.

The CLI creates scheduled routines only. To add API or GitHub triggers, edit the routine on the web. The CLI also supports managing existing routines with /schedule list, /schedule update, and /schedule run.

Key Configuration Details​

  • Prompts must be self-contained: The routine runs without you, so the prompt needs to explain everything — what to look for, how to decide, what to output
  • Scoping matters: What a routine can reach is determined by the repositories you select, environment variables, and connectors. Scope each to what the routine actually needs
  • Branch behavior: Claude creates claude/-prefixed branches by default. Enable "Allow unrestricted branch pushes" if the routine needs to push to other branches
  • Identity: Anything a routine does through your connected GitHub or connectors appears as you — commits carry your GitHub user, Slack messages use your linked account

Trigger Types in Depth​

Schedule Triggers​

Preset frequencies: hourly, daily, weekdays, weekly. Times are entered in your local timezone and converted automatically.

For custom intervals (every two hours, first of each month), pick the closest preset in the web form, then use /schedule update in the CLI to set a specific cron expression. The minimum interval is one hour.

Runs may start a few minutes after the scheduled time due to stagger, but the offset is consistent for each routine.

API Triggers​

Each routine gets a dedicated HTTP endpoint. POSTing with a bearer token starts a new session and returns a session URL you can open to watch the run in real time.

The request body accepts an optional text field for run-specific context (alert body, failing log, etc.). This is passed to the routine alongside its saved prompt as freeform text.

curl -X POST https://api.anthropic.com/v1/claude_code/routines/trig_XXXX/fire \
-H "Authorization: Bearer sk-ant-oat01-xxxxx" \
-H "anthropic-beta: experimental-cc-routine-2026-04-01" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"text": "Sentry alert SEN-4521 fired in prod. Stack trace attached."}'

Each routine has its own token, scoped to triggering that routine only. Tokens are shown once during generation — store them securely in your alerting tool's secret store.

Note: The API ships under an experimental beta header. Breaking changes will ship behind new dated headers, with the two most recent versions supported for migration time.

GitHub Triggers​

A GitHub trigger starts a new session automatically when a matching event occurs. Each matching event fires its own session.

You'll need to install the Claude GitHub App on the repository you want to subscribe to. The trigger setup prompts you to install it if needed.

Important: During research preview, GitHub webhook events are subject to per-routine and per-account hourly caps. Events beyond the limit are dropped until the window resets.

Security and Scoping Considerations​

Routines run autonomously with no approval prompts. This means you need to think carefully about:

  • Repository access: Only select repositories the routine actually needs
  • Environment variables: Provide only the secrets and keys required for the task
  • Network access: Configure the appropriate level of internet access
  • Connectors: Include only the MCP connectors the routine uses

Anything a routine does appears as you — commits carry your GitHub user, connector actions use your linked accounts. Treat routine prompts like production code: clear instructions, error handling, and verification steps.

The Bigger Picture: From Assistants to Agents​

Routines represent an evolution in AI-assisted development. They move us from:

  • Interactive → Autonomous: Claude does work while you're away
  • One-off → Repeatable: Configure once, run forever
  • Task-based → Workflow-based: Entire processes, not just individual actions

This is the direction the industry is heading. Tools like Plain (a Python framework built for agents) and the rise of MCP connectors all point toward a future where AI agents are first-class members of development teams — not just assistants in the IDE, but autonomous workers in the CI/CD pipeline.

The challenge shifts from "how do I get Claude to help me with this?" to "how do I design reliable, trustworthy autonomous workflows?" Prompts become code. Testing becomes crucial. Monitoring and observability matter.

Routines are early days — the feature is in research preview with limits that may change. But they're a clear signal of where AI-assisted development is going.

FAQ​

Q: Do Claude Code Routines require a paid plan? A: Yes, Routines are available on Pro, Max, Team, and Enterprise plans with Claude Code on the web enabled. They're not available on free plans.

Q: Can I share routines with my team? A: During research preview, routines belong to your individual claude.ai account. They're not shared with teammates. Each team member would need to create their own routine, or you'd need to coordinate using shared prompts and configurations.

Q: What happens if a routine fails? A: Each routine run creates a session you can review. If a routine fails or produces unexpected results, you can open the session URL to see what happened, review changes, and continue the conversation manually. You should also add error handling and verification steps to your routine prompts.

Q: Are there limits on how often routines can run? A: Yes, during research preview there are per-routine and per-account hourly limits. The specific limits depend on your plan and are visible at claude.ai/code/routines. Events beyond the limit are dropped until the window resets.

Q: Can routines run concurrently? A: Yes, each trigger event starts its own independent session. A single routine can have multiple sessions running simultaneously if multiple triggers fire in quick succession.