ClawKit Logo
ClawKitReliability Toolkit

Use Case: Coding Assistant

PR reviews ยท test generation ยท refactoring ยท code explanation

What you'll build

An OpenClaw agent that lives in your workflow โ€” review a PR by sending a link, generate tests for a file, explain a function, or refactor a module. Works via Telegram, Discord, or CLI.

Skills you need

The coding assistant use case is powered by three skill categories. Install only what you need โ€” the agent works fine with just the GitHub skill and a capable model.

SkillWhat it unlocksRequired?
github-pr-reviewRead PR diffs, post review comments, approve/request changesCore
github-issuesCreate issues from bugs found during review, reference issue numbersCore
file-readerRead local files for refactoring and explanation tasksCore
test-generatorGenerate unit tests in Jest, Pytest, or Go test formatRecommended
code-explainerExplain code in plain language, generate inline commentsOptional
git-toolsRun git blame, log, and diff for context-aware reviewsOptional

SOUL.md template

The SOUL file defines your agent's identity and behaviour. Save this as SOUL.md in your OpenClaw workspace root and adjust the repo path and review style to your preferences.

SOUL.md โ€” coding assistant
# Coding Assistant

You are a senior software engineer helping with code review, testing, and refactoring.

## Identity
- Name: CodeBot
- Role: Coding assistant for the team's main repo

## Capabilities
- Review pull requests: read the diff, check for bugs, logic errors, security issues, and style
- Generate tests: produce unit tests matching the existing test framework in the repo
- Explain code: describe what a function or module does in plain language
- Refactor: suggest and apply improvements to code structure

## Behaviour
- Be specific: quote the exact line when you flag an issue
- Be constructive: explain *why* something is a problem
- For PRs: summarise the overall quality first, then list specific issues by severity (Critical / Warning / Suggestion)
- For tests: match the existing test framework (auto-detect from package.json or imports)
- When unsure about intent, ask before assuming

## Scope
- Primary repo: ~/projects/my-app
- Do not modify files without explicit confirmation
- Do not post reviews to GitHub until asked to confirm

Config setup

Add the GitHub skill and set a capable model. Claude Sonnet or GPT-4o both work well for code review. DeepSeek V3 is a cost-effective option for high-volume review tasks.

openclaw.json โ€” coding assistant config
{
  "skills": [
    "official-github-pr-review",
    "official-github-issues",
    "official-file-reader",
    "official-test-generator"
  ],
  "model": "claude-sonnet-4-5",
  "soulPath": "./SOUL.md",
  "channel": {
    "type": "telegram",
    "token": "YOUR_BOT_TOKEN",
    "chatId": "YOUR_CHAT_ID"
  }
}

Model cost tip: PR review is token-intensive (large diffs). Use DeepSeek V3 at $0.27/1M tokens for routine reviews and switch to Claude/GPT-4o only for critical PRs. See the Cost Estimator to plan your spend.

Example prompts

Once the agent is running, send these to your Telegram bot or CLI:

PR review

"Review https://github.com/my-org/my-app/pull/142 โ€” focus on security and edge cases"

Generate tests

"Generate unit tests for app/services/auth.ts using Jest"

Explain code

"Explain what the parseConfig function in lib/config.ts does"

Refactor

"Refactor the getUserById function in db/users.ts to use async/await instead of callbacks"

Find bugs

"Check the payment module for potential race conditions or null reference errors"

GitHub integration

To let the agent post review comments directly to GitHub, add a GitHub personal access token with repo scope to your config:

Add GitHub token to config
{
  "env": {
    "GITHUB_TOKEN": "ghp_your_token_here"
  }
}
The agent will read diffs via the GitHub API โ€” no need to clone the repo
Review comments are posted as a single review (not inline comments by default)
To post inline comments, add "post-inline-comments: true" to your SOUL.md behaviour section
Without a token, the agent reads public repos but cannot post comments

Common issues

โš  Agent times out on large PRs

Large diffs exceed context. Add "max diff lines: 500" to your SOUL.md, or ask the agent to review specific files only.

โš  GitHub skill returns 401

Your GITHUB_TOKEN is missing or expired. Generate a new one at github.com/settings/tokens with repo scope.

โš  Tests generated in the wrong framework

Specify the framework explicitly: "Generate tests using Pytest" or add "test framework: jest" to your SOUL.md.

โš  Agent modifies files without confirmation

Add "Do not modify files without explicit confirmation" to your SOUL.md behaviour section.

Did this guide solve your problem?

Need Help?

Try our automated tools to solve common issues instantly.