Why Automate GitHub Issue Management?

Open-source maintainers and engineering teams deal with a flood of GitHub issues every week. Triage alone β€” reading, classifying, assigning labels, pinging the right team members β€” can consume hours that should go into writing code.

OpenClaw AI connects directly to the GitHub CLI and API, letting you describe what you want in plain English while the agent handles the API calls. In this tutorial we will automate four high-value workflows:

  • Auto-triage and label incoming issues by type and severity
  • Generate a first-response comment for common issue categories
  • Create actionable issues directly from runtime errors in your logs
  • Run a daily digest that summarises all open issues for the team
Prerequisites: OpenClaw v1.0+, GitHub CLI (gh) installed and authenticated (gh auth login), and a configured OpenClaw API key. See the installation guide if you are starting fresh.

Step 1 β€” Connect OpenClaw to GitHub CLI

OpenClaw's shell tool allows the agent to run any CLI command. The GitHub CLI (gh) provides a clean, scriptable interface that is much easier to use than raw curl calls to the REST API.

Verify the setup:

# Confirm gh is authenticated
gh auth status

# Confirm OpenClaw can use the shell tool
openclaw run "List the last 3 open issues in openclaw-ai/openclaw" --allow-shell

You should see OpenClaw call gh issue list --repo openclaw-ai/openclaw --limit 3 --state open and return a formatted summary. If it works, you are ready to automate.

Tip: Add allow_shell: true to your ~/.openclaw/config.yaml profile so you do not need the --allow-shell flag every time. Restrict this profile to only the repositories you want the agent to touch.

Step 2 β€” Auto-Triage and Label New Issues

The most common triage pain-point is labeling. OpenClaw can read a batch of unlabeled issues and apply the correct labels based on their content.

# Fetch all unlabeled open issues and triage them
openclaw run --allow-shell "
Fetch all open issues in openclaw-ai/openclaw that have no labels (use gh issue list).
For each issue, read its body and title, then apply the most appropriate label from:
  bug, enhancement, documentation, question, wontfix, good first issue, help wanted.

Use: gh issue edit <number> --add-label <label> --repo openclaw-ai/openclaw

Print a table: issue number | title | label applied.
"

Automate with a Shell Script

Wrap the command in a script you can schedule daily:

#!/usr/bin/env bash
# scripts/triage-issues.sh
set -euo pipefail

REPO="${GITHUB_REPO:-openclaw-ai/openclaw}"

echo "=== Triaging unlabeled issues in $REPO ==="
openclaw run --allow-shell "
Fetch all open issues with no labels in $REPO using gh issue list.
For each issue: read its body, classify it as one of:
  bug / enhancement / documentation / question / good first issue
Apply the label with: gh issue edit  --add-label 
Safety note: Always run this against a test repository first. OpenClaw will execute real gh commands that mutate your repository data. Use --dry-run mode (or add "do not apply labels, only print what you would do" to the prompt) before enabling live mutations.

Step 3 β€” First-Response Comments for Common Issues

Many issues fall into predictable categories: installation errors, configuration questions, feature requests for something already documented. OpenClaw can detect these patterns and post a helpful first-response comment faster than any human reviewer.

openclaw run --allow-shell "
Fetch open issues in openclaw-ai/openclaw that:
  1. Are labeled 'question' AND have zero comments, OR
  2. Body contains 'how do I' or 'how to'

For each such issue:
  a. Read the full issue body.
  b. Check our documentation at https://openclaw-wiki.top to find a relevant answer.
  c. Post a helpful comment using:
     gh issue comment <number> --body '...' --repo openclaw-ai/openclaw

The comment should:
  - Greet the author by their GitHub handle
  - Answer the question directly with a code snippet or a documentation link
  - End with 'Feel free to reopen if this doesn't solve your problem.'

Print: commented on issue #<number> β€” <title>
"

Pre-Built Response Templates

Create a prompts/issue-response.txt file for consistent responses:

cat prompts/issue-response.txt
# You are a helpful OpenClaw maintainer. Always be friendly and technically accurate.
# If you cannot find a definitive answer, say so and ask clarifying questions.
# Never close an issue; only comment. Never apply labels unless explicitly told to.

openclaw run --prompt-file prompts/issue-response.txt --allow-shell \
  "Handle new unanswered questions in openclaw-ai/openclaw" \
  --model gpt-4o

Step 4 β€” Create Issues from Runtime Errors

One of the most powerful integrations is creating GitHub issues automatically from application errors in your logs. Add this to your CI pipeline or cron job:

#!/usr/bin/env bash
# scripts/errors-to-issues.sh
# Usage: ./errors-to-issues.sh /var/log/app-error.log

LOG_FILE="${1:-/var/log/app-error.log}"
REPO="${GITHUB_REPO:-openclaw-ai/openclaw}"
CUTOFF="1 hour ago"

# Extract errors from the last hour
RECENT_ERRORS=$(journalctl --since="$CUTOFF" -p err 2>/dev/null \
  || tail -n 200 "$LOG_FILE")

openclaw run --allow-shell "
Analyse these application errors and decide which ones are worth filing as GitHub issues.
Errors: $RECENT_ERRORS

Rules:
- Skip errors that already have an open issue (use: gh issue list --search 'error text')
- Skip errors that are known false positives (rate limits, transient network errors)
- For each new, actionable error:
  a. Write a clear title: '[BUG] <short description>'
  b. Write a body with: summary, stack trace (code-fenced), steps to reproduce if obvious, environment info
  c. Create the issue: gh issue create --title '...' --body '...' --label bug --repo $REPO
  d. Print: created issue #<number> for <error type>
"
Deduplication tip: The prompt instructs OpenClaw to search for existing issues before creating new ones. You can make this more aggressive by adding: "If a similar issue exists that is less than 7 days old, add a comment to it instead of creating a new issue."

Step 5 β€” Daily Issue Digest for the Team

Replace manual standup issue reviews with an automated daily digest posted to your team's Slack or saved as a Markdown report:

#!/usr/bin/env bash
# scripts/daily-digest.sh
set -euo pipefail

REPO="${GITHUB_REPO:-openclaw-ai/openclaw}"
DATE=$(date +%Y-%m-%d)
OUTPUT="digests/issues-$DATE.md"
mkdir -p digests

openclaw run --allow-shell "
Fetch all open issues in $REPO using gh issue list --state open --limit 100.
Generate a team digest in Markdown with these sections:

## πŸ”΄ Critical (labeled: bug, priority:high) β€” needs action today
## 🟑 Open PRs Ready for Review
## πŸ“‹ New Issues This Week
## πŸ“Š Stats: total open, opened this week, closed this week

Use gh commands to fetch additional data as needed.
Format each issue as: #number β€” title (author, age, labels)
Keep each section short and scannable.
" > "$OUTPUT"

echo "=== Daily Digest saved to $OUTPUT ==="
cat "$OUTPUT"

Post to Slack via Webhook

# After generating the digest, post to Slack
DIGEST=$(cat "$OUTPUT")
curl -s -X POST "$SLACK_WEBHOOK_URL" \
  -H 'Content-type: application/json' \
  --data "{\"text\": \"*Daily GitHub Issues Digest β€” $DATE*\n\`\`\`${DIGEST:0:2900}\`\`\`\"}"

Step 6 β€” Scheduling with GitHub Actions

Run these automations on a schedule using a GitHub Actions workflow. The agent runs inside your CI environment where gh is already authenticated via GITHUB_TOKEN:

# .github/workflows/issue-automation.yml
name: Issue Automation

on:
  schedule:
    - cron: '0 9 * * 1-5'   # 09:00 UTC, Mon–Fri
  workflow_dispatch:          # allow manual trigger

jobs:
  triage:
    runs-on: ubuntu-latest
    permissions:
      issues: write
      contents: read
    steps:
      - uses: actions/checkout@v4

      - name: Install OpenClaw
        run: pip install openclaw

      - name: Configure OpenClaw
        run: |
          mkdir -p ~/.openclaw
          echo "provider: openai" > ~/.openclaw/config.yaml
          echo "model: gpt-4o-mini" >> ~/.openclaw/config.yaml
          echo "allow_shell: true" >> ~/.openclaw/config.yaml
        env:
          OPENCLAW_API_KEY: ${{ secrets.OPENCLAW_API_KEY }}

      - name: Triage unlabeled issues
        run: bash scripts/triage-issues.sh
        env:
          GITHUB_REPO: ${{ github.repository }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Generate daily digest
        run: bash scripts/daily-digest.sh
        env:
          GITHUB_REPO: ${{ github.repository }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Cost control: Using gpt-4o-mini for triage and labeling is 20Γ— cheaper than gpt-4o and more than accurate enough. Reserve the stronger model for the first-response generator where response quality matters more.

Advanced Patterns

Stale Issue Closer

Automatically close issues that have been inactive for 90 days with a helpful message:

openclaw run --allow-shell "
Find all open issues in $REPO that:
  - Have no activity (comments or label changes) in the last 90 days
  - Are NOT labeled 'pinned' or 'roadmap'

For each stale issue:
  1. Post: 'This issue has been inactive for 90 days. Closing as stale β€” reopen if still relevant.'
     Command: gh issue comment <n> --body '...' --repo $REPO
  2. Close it: gh issue close <n> --repo $REPO

Print: closed #<n> β€” <title>
"

Duplicate Detection

Find and link duplicate issues to reduce noise in your tracker:

openclaw run --allow-shell "
Fetch the 50 most recent open issues in $REPO using gh issue list.
Group issues by semantic similarity (read their bodies carefully).
For any group of 2+ issues that appear to describe the same problem:
  - On the newest duplicate, post a comment: 'Possible duplicate of #<oldest number>'
  - Apply the 'duplicate' label: gh issue edit <n> --add-label duplicate

Print: possible duplicate pairs found.
" --model gpt-4o

Best Practices and Safety

PracticeWhy It Matters
Use --dry-run firstPreview all gh commands before they execute
Restrict to one repo per runAvoids accidental cross-repo mutations
Log every actionAudit trail for team transparency
Use gpt-4o-mini for bulk tasksReduces cost by 20Γ— with minimal quality loss
Never auto-close without a commentRespects contributors and explains the action
Rotate API keysUse dedicated keys for CI, not your personal key
Important: Always use a scoped GITHUB_TOKEN with the minimum required permissions (issues: write only). Never give OpenClaw your personal access token with full repo access in a shared CI environment.