iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🛌

Put Claude Code Actions to Work While You Sleep

に公開
7

Claude Code Actions (CCA) are now available on the Max plan.

https://x.com/schroneko/status/1942432524132835827

Now, while it's great that Claude Code Actions can be used on the Max plan, the issue is the usage limits.
If I use it even for CCA, I expect I'll hit the limit in no time during the day and become unable to develop any further.

Running it while you sleep?

If you could run it while you sleep, it might solve the problem to some extent.
This way, you can use it as usual during the day, while development progresses on its own at night.

This might be the "passive coding life." They say "there's no time like the present," so for the sake of a good night's sleep, I've hurriedly built a mechanism to request tasks from Claude Code Action while I sleep.

I referred to this article regarding support for Claude Code Actions on the Max plan:
https://zenn.dev/aokkey/articles/7dca9b62cca467

GitHub Actions to periodically pick up issues at night

So, I created a workflow that periodically picks up issues in order of priority during the night and sends them to CCA (of course, Claude Code created this too).

  1. GitHub Actions starts every 30 minutes at night (23:00 to 06:00).
  2. Select one unprocessed Issue in order of priority (high → middle → low).
  3. Automatically post a comment containing a @claude mention to the selected Issue.
  4. Claude Code Action is triggered, and the AI performs code fixes.

Since this is v0.1, it's a simple implementation that just looks for existing issues and makes a comment with a @claude mention according to the rules.
The 30-minute interval is just a result of balancing operation checks and execution frequency based on "vibes"; there's no strong technical reason behind it.

GitHub Actions and n8n were both considered for the implementation, but I'll go with GitHub Actions this time (I want to migrate to n8n, but the GitHub node's Issue action didn't have "List," so this is a temporary fix).
https://n8n.io/

Claude Code Action does not respond to comments from GitHub Apps, so I'm using a PAT for now.

name: Auto Issue Resolver

on:
  schedule:
    # Runs every 30 minutes between 23:00-06:00 JST
    # JST = UTC + 9 hours
    # JST 23:00 = UTC 14:00, JST 06:00 = UTC 21:00
    - cron: '0,30 14-20 * * *'  # UTC 14:00-20:30 (JST 23:00-05:30)
    - cron: '0 21 * * *'        # UTC 21:00 (JST 06:00)
  workflow_dispatch: # Manual execution is also possible

jobs:
  process-issue:
    runs-on: ubuntu-latest
    
    steps:
      - name: Find and process highest priority issue
        uses: actions/github-script@v7
        with:
          # Use Personal Access Token (if not set, use GITHUB_TOKEN)
          github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
          script: |
            // Look for issues in order of priority
            const priorities = ['high', 'middle', 'low'];
            const processedLabel = 'claude-code-requested';
            
            for (const priority of priorities) {
              // Get issues with priority labels (descending by creation date)
              const issues = await github.rest.issues.listForRepo({
                owner: context.repo.owner,
                repo: context.repo.repo,
                labels: priority,
                state: 'open',
                sort: 'created',
                direction: 'desc',
                per_page: 100
              });
              
              // Find unprocessed issues
              const unprocessedIssue = issues.data.find(issue => 
                !issue.labels.some(label => label.name === processedLabel)
              );
              
              if (unprocessedIssue) {                
                // Post @claude mention comment
                await github.rest.issues.createComment({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  issue_number: unprocessedIssue.number,
                  body: [
                    `@claude Please resolve this Issue #${unprocessedIssue.number}.`,
                    '',
                    'Please propose a specific implementation plan and necessary code changes based on the following:',
                    '',
                    `**Title**: ${unprocessedIssue.title}`,
                    '',
                    '**Description**:',
                    unprocessedIssue.body || 'No description',
                    '',
                    `Priority: ${priority}`
                  ].join('\n')
                });
                
                // Add processed label
                await github.rest.issues.addLabels({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  issue_number: unprocessedIssue.number,
                  labels: [processedLabel]
                });
                
                console.log('Claude Code Action will be triggered by the mention');
                return; // Process only one issue and exit
              }
            }
            
            console.log('No unprocessed issues found');

# ... (omitted)

I had Claude Code create this based on "vibes," so I haven't looked at the details too closely, but it seems to be working, so that's good for now.

And after waiting for several tens of minutes, I confirmed that the scheduled execution actually worked! 🎉
Now, by creating issues in advance and adding labels, requests are automatically sent to Claude Code Action while I sleep.

The claude-code-requested label is also properly applied.

Picking up Slack logs to create issues

Next, I'm thinking about issue creation. While one might say I should just create issues manually before bed, I'd like to solve this with a mechanism.

So, I also created a workflow to periodically pick up messages from specific Slack channels and automatically create issues. I'll have the LLM analyze and break down the content before creating the issues.

This time, I'm just creating issues arbitrarily from Slack message history, but if I link this with an error log channel, it will become a world where errors are fixed automatically (I'll do that tomorrow).

Summary

With this, a system that automatically resolves Issues at night was born.
I made something similar back when the Devin API was available, but it was hard to sustain because I couldn't predict the costs for personal development, so I had stopped. I'm happy to be able to realize this again with Claude Code Action.

I've built this all at once by relying on Claude Code, but I'm now feeling a desire to grow it into a much richer system.
Since my personal development repositories have PR preview environments set up, depending on the task, I might even be able to check the behavior and merge it on the spot when I wake up in the morning.
(For example, if the behavior is guaranteed by Unit Tests, etc.)

I implemented this and wrote the article all in one go, but for now, I'll head to bed, looking forward to it resolving the sad problem of finding "any" types left in my code when I wake up.

That's all for this time!

Discussion

KKKK

githubにいくらぐらい課金しそうになりそうですか

わたなおわたなお

めっちゃやりたい!!!でも、技術力というか、Issueに詳細の記載をかなり頑張らないといけなさそうなのとMaxっていう点なのが今の自分には課題かもしれないです 😢

ShuShu

全部AIでやりましょう!gh コマンドでタスク分解してもらったものをイシューに起票でOKです

michemiche

日中利用しつつ夜間もMaxプランで1セッション使うと
月間50セッション制限に引っ掛かりやすくなりませんか?
厳密な制限ではないらしいですが