Code Review on Change — YAML Workflow
Automated AI code review triggered by source file changes. When files change in a watched directory, InTouch captures the git diff, sends it to Claude for review, and posts the results to your team.
How It Works
- A Trigger File watches your source code directory for changes
- When a file changes, this workflow fires
- Bash runs
git diffto capture what changed - Claude reviews the diff — bugs, security, performance, error handling
- The review is posted to your team via any messaging channel
Setup
1. Edit the Workflow
Open code-review-on-change.yaml and update:
# In the get-diff task, change the project path:
script: |
cd /home/user/projects/myapp # <-- your repo path
git diff HEAD~1 --unified=5 --stat
echo "---DIFF---"
git diff HEAD~1 --unified=5
# In the review task, change the connection name:
connection: claude-api # <-- your Anthropic connection name
# In the notify-team task, change the contact:
contactNames: "dev-team" # <-- your contact or group name
2. Create an Anthropic Connection
In the UI: Connections > Add Connection
- Type: Anthropic
- Name:
claude-api(or whatever you used in the workflow) - API Key: Your Anthropic API key
3. Create a Trigger File
In the UI: Automation > Trigger Files > Add
- Path: Your source code directory (e.g.,
/home/user/projects/myapp/src) - Recursive: Yes (to catch changes in subdirectories)
4. Link the Workflow to the Trigger
In the UI: Workflow Management > code-review-on-change > Triggers
Link the trigger file you created to this workflow.
5. Create a Contact
In the UI: Users & Privileges > Subscribers
Create a contact (or group) named dev-team with the channels your team uses — Slack, Teams, email, etc.
Customization
Change the Review Focus
Edit the systemPrompt in the review task:
systemPrompt: |
You are a senior code reviewer. Focus on:
- Security vulnerabilities (SQL injection, XSS, auth bypasses)
- Performance issues (N+1 queries, unnecessary allocations)
- Error handling gaps (uncaught exceptions, missing null checks)
# Add your own priorities here
Change the Diff Range
The default reviews the last commit (HEAD~1). Change for different scenarios:
# Last 3 commits
git diff HEAD~3 --unified=5
# Changes since a branch point
git diff main...HEAD --unified=5
# Only staged changes
git diff --cached --unified=5
# Changes in the last hour
git diff HEAD@{1.hour.ago} --unified=5
Change the AI Model
model: claude-sonnet-4-6 # balanced (default)
model: claude-opus-4-6 # most thorough
model: claude-haiku-4-5-20251001 # fastest, cheapest
Filter by File Type
Add file type filters to the git diff:
# Only review Python files
git diff HEAD~1 --unified=5 -- "*.py"
# Only review Kotlin and Java
git diff HEAD~1 --unified=5 -- "*.kt" "*.java"
# Exclude test files
git diff HEAD~1 --unified=5 -- . ":!**/test/**"
Cost
- Claude Sonnet: ~$0.01-0.05 per review (depending on diff size)
- Claude Haiku: ~$0.002-0.01 per review
- A team committing 20 times/day: $0.20-1.00/day
Notes
- The
bashruntime environment is auto-created by InTouch on Linux/macOS install (from/bin/bash) — no setup needed there - Windows: InTouch auto-creates
powershellandcommand promptinstead, NOTbash. To run on Windows: install Git Bash or WSL and add abashruntime env in InTouch pointing at it (e.g.C:\Program Files\Git\bin\bash.exe), OR changeruntimeEnvName: "bash"to"powershell"and rewrite thegit diffscript in PowerShell - Git must be installed and the repo must be cloned locally
- The workflow uses
HEAD~1by default — adjust if your workflow squashes commits - Large diffs may exceed Claude's context window — consider filtering by file type for large repos