---
name: pr-review-daemon
description: |
  Polls GitHub for new PRs, performs AI code review, and posts results to Feishu.
  Runs as a background daemon, checking every 60 seconds.
---

# PR Review Daemon

Automated PR monitoring and code review daemon.

## Usage

```bash
bash run.sh start   # Start daemon
bash run.sh stop    # Stop daemon
bash run.sh status  # Check status
bash run.sh once    # Single poll (testing)
```

## How It Works

1. Poll GitHub every 60 seconds for new PRs (created within last 10 min)
2. When new PR found:
   - Send notification to Feishu group with @mention to trigger AI
   - Fetch PR diff and analyze changes
   - Post basic analysis to Feishu
   - Add to queue for deep AI review
3. Track processed PRs to avoid duplicates

## Features

- **Automatic @mention** - Notifies AI immediately when new PR is detected
- **Basic code analysis** - Checks for TODOs, secrets, security-sensitive changes
- **Large PR detection** - Warns about oversized PRs
- **Queue system** - Falls back to queue @mention doesn't trigger AI

## Configuration

Create `~/.config/team-code-expert/config.env`:

```bash
# GitHub App
GITHUB_APP_ID="your_app_id"
GITHUB_INSTALLATION_ID="your_installation_id"
GITHUB_PRIVATE_KEY="$HOME/.ssh/github-app.pem"

# Feishu
FEISHU_APP_ID="your_app_id"
FEISHU_APP_SECRET="your_secret"
FEISHU_CHAT_ID="your_chat_id"
FEISHU_BOT_OPEN_ID="your_bot_open_id"  # Optional, for @mention

# Optional
POLL_INTERVAL=60
```

## Watched Repos

Edit `WATCH_REPOS` in run.sh to add/remove repositories.

## Files

- `run.sh` - Daemon script
- `SKILL.md` - This documentation

## Troubleshooting

### AI doesn't respond immediately

1. Check that `FEISHU_BOT_OPEN_ID` is set in config
2. Check daemon logs: `tail -f /tmp/pr-review-daemon.log`
3. AI should respond to @mention in the group

### Daemon not running

```bash
bash run.sh status  # Check status
bash run.sh start   # Start daemon
```
