Skip to main content
Automated GitHub issue analysis using Cline CLI. This script uses Cline’s autonomous AI capabilities to fetch, analyze, and identify root causes of GitHub issues, outputting clean, parseable results that can be easily integrated into your development workflows.
New to Cline CLI? This sample assumes you have already completed the Installation Guide and authenticated with cline auth. If you haven’t set up Cline CLI yet, please start there first.
CLI Root Cause Analysis Demo

Prerequisites

This sample assumes you have already:
  • Cline CLI installed and authenticated (Installation Guide)
  • At least one AI model provider configured (e.g., OpenRouter, Anthropic, OpenAI)
  • Basic familiarity with Cline CLI commands
Additionally, you’ll need:
  • GitHub CLI (gh) installed and authenticated
  • jq installed for JSON parsing
  • bash shell (or compatible shell)

Installation Instructions

macOS

These instructions require Homebrew to be installed. If you don’t have Homebrew, install it first by running:

Linux

Getting the Script

Option 1: Download directly with curl
Option 2: Copy the full script
After downloading or creating the script, make it executable by running:

Quick Usage Examples

Basic Usage

Run this command in your terminal from the directory where you saved the script to analyze an issue with the default root cause prompt:
This will:
  • Fetch issue #123 from the repository
  • Analyze the issue to identify root causes
  • Provide detailed analysis with recommendations

Custom Analysis Prompt

Ask specific questions about the issue:
The script will automatically handle everything: fetching the issue, analyzing it with Cline, and displaying the results. The analysis typically takes 30-60 seconds depending on the issue complexity.

How It Works

Let’s analyze each component of the script to understand how it works.

Argument Validation

The script validates input and provides usage instructions:
Key Points:
  • Validates required GitHub issue URL
  • Shows clear usage examples
  • Supports optional custom prompt

Argument Parsing

The script extracts and sets up the arguments:
Explanation:
  • ISSUE_URL="$1" - First argument is always the issue URL
  • PROMPT="${2:-...}" - Second argument is optional, defaults to root cause analysis
  • The SDK CLI runs the task directly, so no address flag is required.

The Core Analysis Pipeline

This is where the magic happens:
1. cline --auto-approve true --json "$PROMPT: $ISSUE_URL"
  • cline is the Cline CLI binary
  • Act mode is the default for prompt runs
  • --auto-approve true allows tool use without interactive prompts
  • --json emits newline-delimited JSON for parsing
  • Constructs prompt with issue URL
2. jq -r 'select(.type == "agent_event" and .event.type == "done") | .event.text'
  • Filters for the final agent done event
  • Extracts the final text field
  • -r outputs raw strings (no JSON quotes)
3. sed 's/\\n/\n/g'
  • Converts escaped newlines to actual newlines
  • Makes output readable

Sample Output

Here’s an example analyzing a real Flutter issue:
Output:

When to Use This Pattern

This script pattern is ideal for various development scenarios where automated GitHub issue analysis can accelerate your workflow.

Bug Investigation

Quickly analyze bug reports and identify root causes without manual code exploration:

Feature Request Analysis

Understand context and implications of feature requests:

Security Audits

Assess security implications of reported issues:

Documentation Generation

Generate detailed technical documentation from issues:

Code Review Assistance

Get second opinions on proposed changes:

Conclusion

This sample demonstrates how to build an autonomous GitHub issue analysis tool using Cline CLI:
  1. Building autonomous CLI tools using Cline’s capabilities
  2. Parsing structured JSON output from Cline CLI
  3. Creating flexible automation scripts with custom prompting
  4. Integrating with GitHub for issue analysis
  5. Handling command-line arguments effectively
This pattern can be adapted for many other automation scenarios, from pull request reviews to documentation generation to code quality analysis.