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.
Jump to section
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.
| Skill | What it unlocks | Required? |
|---|---|---|
| github-pr-review | Read PR diffs, post review comments, approve/request changes | Core |
| github-issues | Create issues from bugs found during review, reference issue numbers | Core |
| file-reader | Read local files for refactoring and explanation tasks | Core |
| test-generator | Generate unit tests in Jest, Pytest, or Go test format | Recommended |
| code-explainer | Explain code in plain language, generate inline comments | Optional |
| git-tools | Run git blame, log, and diff for context-aware reviews | Optional |
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.
# 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.
{
"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:
{
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}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?