# XII. Protocol Self-Check Mechanism

## 12.1 Importance of Protocol Self-Check

> **When using the protocol, we often find that things get missed during dialogue -- such as forgetting to commit to git, or failing to update a corresponding document.**

The protocol self-check mechanism helps the AI and users ensure compliance with all collaboration protocol requirements.

## 12.2 Self-Check Trigger Methods

### Method 1: Command Line Check

```bash
# Check protocol compliance
vibecollab check

# Strict mode (warnings treated as failures)
vibecollab check --strict

# Include Insight consistency check (v0.7.0+)
vibecollab check --insights
```

### Method 2: Dialogue Trigger

Use the following trigger phrases in dialogue, and the AI should proactively execute a protocol self-check:

- "check protocol"
- "protocol check"
- "self-check"
- "verify compliance"

## 12.3 Check Items

The protocol checker verifies the following:

### Git Protocol Check
- [x] Whether the project has initialized a Git repository
- [x] Whether there are uncommitted changes
- [!] Git commit frequency (reminder for long periods without commits)

### Documentation Update Check
- [x] Whether required documents exist (CONTEXT.md, CHANGELOG.md, etc.)
- [!] Whether documents are recently updated (within 24 hours)
- [x] Whether PRD.md exists (if enabled)

### Dialogue Flow Check
- [x] Whether files that should be read at dialogue start exist
- [x] Whether files that should be updated at dialogue end exist

## 12.4 Check Results

Check results are classified into three levels:

| Level | Symbol | Description | Action Required |
|-------|--------|-------------|-----------------|
| **Error** | [FAIL] | Protocol violation | Must fix |
| **Warning** | [WARN] | Potentially missed protocol step | Recommended to address |
| **Info** | [INFO] | Informational notice | Optional |

## 12.5 AI Self-Check Behavior Guidelines

When the user triggers a protocol self-check, the AI should:

1. **Execute check**: Run the protocol checker, obtain results
2. **Display results**: Clearly show the status of all check items
3. **Provide suggestions**: For failed items, provide specific fix suggestions
4. **Auto-fix**: For auto-fixable issues (e.g., updating docs), proactively execute fixes
5. **Record reminders**: For issues requiring manual handling, clearly remind the user

## 12.6 Self-Check Best Practices

### At Dialogue Start
- After restoring context, run a quick self-check to ensure the environment is normal

### At Dialogue End
- Before executing git commit, run self-check to ensure all protocol requirements are met

### Periodic Check
- If there has been a long gap since the last dialogue, run a full self-check when resuming

---

