# Project Setup for Automatic Reviews

## Required Structure

In your project, create the following structure:

```
.claude/
├── reviews/
│   └── config.json          # Review configuration
└── skills/
    └── review-{{type}}/     # Review skill
        └── SKILL.md
```

## 1. Configuration (`config.json`)

Copy `config.json.template` to `.claude/reviews/config.json`:

```json
{
  "github": false,
  "gitlab": true,
  "defaultModel": "opus",
  "reviewSkill": "review-front",
  "reviewFollowupSkill": "review-followup",
  "agents": [
    { "name": "clean-architecture", "displayName": "Clean Archi" },
    { "name": "ddd", "displayName": "DDD" },
    { "name": "testing", "displayName": "Testing" },
    { "name": "code-quality", "displayName": "Code Quality" }
  ]
}
```

### Options

| Field | Type | Description |
|-------|------|-------------|
| `github` | boolean | Enable GitHub webhooks |
| `gitlab` | boolean | Enable GitLab webhooks |
| `defaultModel` | string | Claude model (`opus`, `sonnet`, `haiku`) |
| `reviewSkill` | string | Main review skill name |
| `reviewFollowupSkill` | string | Follow-up skill name |
| `agents` | array | Agent list for the dashboard |

### Agents

Agents define what appears on the dashboard:

```json
{
  "name": "clean-architecture",   // Unique ID (kebab-case)
  "displayName": "Clean Archi"    // Display name
}
```

**Important**: Agent names must match the `[PROGRESS:name:status]` markers in the skill.

---

## 2. Review Skill (`SKILL.md`)

Copy `SKILL.md.template` to `.claude/skills/review-{{type}}/SKILL.md`.

### Customization

1. Replace `{{...}}` variables
2. Define your audit agents
3. Adapt rules to your project

### Required Markers

For real-time tracking, the skill must emit:

```
[PHASE:initializing]           # Starting
[PHASE:agents-running]         # Agents running
[PROGRESS:agent-name:started]  # Agent started
[PROGRESS:agent-name:completed]# Agent completed
[PHASE:synthesizing]           # Synthesis
[PHASE:publishing]             # Publishing
[PHASE:completed]              # Done

[REVIEW_STATS:blocking=X:warnings=X:suggestions=X:score=X]
```

---

## 3. Server Configuration

Auto-generated by `reviewflow init` in `~/.claude-review/config.json`:

```json
{
  "server": {
    "port": 3847
  },
  "user": {
    "gitlabUsername": "your-gitlab-username",
    "githubUsername": "your-github-username"
  },
  "queue": {
    "maxConcurrent": 2,
    "deduplicationWindowMs": 300000
  },
  "repositories": [
    {
      "name": "project-name",
      "localPath": "/path/to/project",
      "enabled": true
    }
  ]
}
```

Webhook secrets are stored separately in `~/.claude-review/.env`:

```env
GITLAB_WEBHOOK_TOKEN=<auto-generated>
GITHUB_WEBHOOK_SECRET=<auto-generated>
```

> Run `reviewflow init --show-secrets` to view your webhook secrets after setup.

---

## 4. Webhooks

### GitLab

1. Go to **Settings > Webhooks**
2. URL: `http://your-server:3847/webhooks/gitlab`
3. Secret Token: your `webhookSecretGitlab`
4. Trigger: `Merge request events`

### GitHub

1. Go to **Settings > Webhooks**
2. URL: `http://your-server:3847/webhooks/github`
3. Secret: your `webhookSecretGithub`
4. Events: `Pull requests`

---

## 5. Verification

1. Assign yourself as reviewer on a MR/PR
2. Check the dashboard: http://localhost:3847
3. The review should trigger automatically

---

## Specialized Skill Examples

### Frontend (React/Vue/Angular)

```json
{
  "agents": [
    { "name": "clean-architecture", "displayName": "Clean Archi" },
    { "name": "react-best-practices", "displayName": "React" },
    { "name": "solid", "displayName": "SOLID" },
    { "name": "testing", "displayName": "Testing" },
    { "name": "accessibility", "displayName": "A11y" },
    { "name": "code-quality", "displayName": "Quality" }
  ]
}
```

### Backend (Node/Python/Go)

```json
{
  "agents": [
    { "name": "clean-architecture", "displayName": "Clean Archi" },
    { "name": "ddd", "displayName": "DDD" },
    { "name": "solid", "displayName": "SOLID" },
    { "name": "api-design", "displayName": "API Design" },
    { "name": "security", "displayName": "Security" },
    { "name": "testing", "displayName": "Testing" }
  ]
}
```

### API (REST/GraphQL)

```json
{
  "agents": [
    { "name": "api-design", "displayName": "API Design" },
    { "name": "security", "displayName": "Security" },
    { "name": "performance", "displayName": "Performance" },
    { "name": "documentation", "displayName": "Documentation" },
    { "name": "testing", "displayName": "Testing" }
  ]
}
```
