Code Quality Agents
AI-powered agents for code review, test coverage, and CI failure remediation, powered by Claude AI and integrated into your Harness pipelines.
Harness provides three AI-powered agents focused on code quality: Code Review for intelligent PR feedback, Code Coverage for automated test generation, and Autofix for automatic CI failure remediation. These agents use Claude AI to analyze code, generate improvements, and submit changes via pull requests.
Code Review Agent
The Code Review agent automatically reviews code changes in pull requests and posts intelligent feedback directly to the PR. It uses a three-stage process for comprehensive analysis.
How it works
Review Prompt Generation: An analysis agent examines the PR diff and generates a targeted review prompt
AI Code Review: Claude AI (up to 50 iterations) performs comprehensive code review following the generated prompt
Comment Posting: Review comments are posted directly to the PR via Harness SCM
Key inputs
anthropicKey
secret
Anthropic API key for Claude AI
harnessKey
secret
Harness API key for SCM operations
repo
string
Repository name
pullReq
string
Pull request number
Pipeline configuration
pipeline:
clone:
depth: 1000
ref:
type: pull-request
number: <+inputs.pullReq>
repo: <+inputs.repo>
stages:
- name: review
steps:
- name: review_prompt_generation_agent
run:
container:
image: abhinavharness/drone-ai-review:latest
with:
output_file: /harness/.../task.txt
review_output_file: /harness/.../review.json
working_directory: /harness
- name: coding_agent
run:
container:
image: anewdocker25/mydockerhub:coding-agent
with:
detailed_logging: "true"
max_iterations: "50"
task_file_path: /harness/.../task.txt
working_directory: /harness
show_diff: "false"
env:
ANTHROPIC_API_KEY: <+inputs.anthropicKey>
- name: post_comments
run:
container:
image: abhinavharness/comment-plugin:latest
with:
comments_file: /harness/.../review.json
repo: <+inputs.repo>
pr_number: <+inputs.pullReq>
env:
TOKEN: <+inputs.harnessKey>
platform:
os: linux
arch: arm64
inputs:
anthropicKey:
type: secret
default: account.autofix_anthropic_api_key
harnessKey:
type: secret
default: account.harness_api_key
repo:
type: string
required: true
pullReq:
type: string
required: true
name: codereviewCode Coverage Agent
The Code Coverage agent analyzes codebases and generates comprehensive unit tests to achieve 90%+ code coverage. It creates a detailed COVERAGE.md report, pushes changes to a new branch, and posts coverage results as a PR comment.
How it works
Codebase Analysis: Scans source files and identifies coverage gaps.
Test Generation: Claude AI (up to 300 iterations) generates comprehensive unit tests.
Coverage Verification: Runs tests and verifies coverage targets are met.
Report Generation: Creates a COVERAGE.md with per-file coverage breakdown.
PR Creation: Pushes to a unique branch and creates a PR with coverage report as a comment.
Coverage targets
90% overall code coverage target
80% minimum per-file coverage
Auto-posted coverage reports on PR
Go language support with verification enabled
Key inputs
llmConnector
connector
LLM connector for AI operations
harnessKey
secret
Harness API key
gitConnector
connector
Git connector for repository access
repo
string
Repository name
branch
string
Target branch
Pipeline configuration
Autofix Agent
The Autofix agent automatically diagnoses and fixes CI pipeline failures. When a CI build fails, the agent analyzes execution logs, generates a diagnosis, applies code fixes using Claude AI, and creates a PR with the solution.
How it works
Log Analysis: Fetches execution logs from the failed CI pipeline.
Diagnosis: A remediation agent analyzes the failure and identifies the root cause.
Fix Generation: A coding agent (Claude AI, up to 50 iterations) applies code changes to fix the issue.
Branch & PR: Pushes fixes to an
ai-autofixbranch and creates a pull request.
Two-stage AI process
Remediation Agent: Specializes in diagnosing CI failures from logs and error messages.
Coding Agent: Takes the diagnosis and applies targeted code fixes.
Key inputs
llmConnector
connector
LLM connector for AI operations
harnessKey
secret
Harness API key
gitConnector
connector
Git connector for repository access
repo
string
Repository name
branch
string
Target branch
executionId
string
Failed pipeline execution ID
Pipeline configuration
Last updated
Was this helpful?