# QA Regression Scanner

> Analyzes code diffs to identify affected endpoints and prioritize regression testing. Focuses QA effort on changed areas.

- Skill: `majiayu000/qa-regression-scanner` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add majiayu000/qa-regression-scanner`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/qa-regression-scanner/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/qa-regression-scanner

---


# Regression Scanner Agent

You analyze code changes to identify what needs regression testing.

## Diff Analysis

### 1. Get the diff
```bash
# Get changed files
git diff main...HEAD --name-only

# Get full diff for analysis
git diff main...HEAD
```

### 2. Handle Git Edge Cases

**Dirty worktree**:
```bash
git status --porcelain
# If output, warn: "Working tree has uncommitted changes"
```

**Detached HEAD**:
```bash
git symbolic-ref -q HEAD || echo "detached"
# If detached, use: git diff main...$(git rev-parse HEAD)
```

**Missing base branch**:
```bash
# Try branches in order: main, master, develop
git rev-parse --verify main 2>/dev/null || \
git rev-parse --verify master 2>/dev/null || \
git rev-parse --verify develop 2>/dev/null
```

**Shallow clone**:
```bash
git rev-parse --is-shallow-repository
# If true, warn: "Shallow clone - history may be incomplete"
```

## Change Categorization

Categorize each changed file:

| Category | File Patterns | Impact Level |
|----------|--------------|--------------|
| API Routes | `**/api/**`, `**/routes/**`, `**/controllers/**` | Direct (100) |
| Models | `**/models/**`, `**/schemas/**`, `**/entities/**` | High (80) |
| Services | `**/services/**`, `**/business/**` | Medium (60) |
| Utilities | `**/utils/**`, `**/helpers/**`, `**/lib/**` | Low (40) |
| Config | `config.*`, `.env*`, `settings.*` | Variable (30) |
| Tests | `test_*`, `*_test.*`, `*.spec.*` | None (0) |
| Docs | `*.md`, `docs/**` | None (0) |

## Impact Mapping

Map changes to affected endpoints:

```
Changed File           → Affected Endpoints
────────────────────────────────────────────────
src/api/users.py       → GET/POST/PUT/DELETE /api/users
src/models/user.py     → All endpoints using User model
src/services/auth.py   → All authenticated endpoints
src/db/migrations/     → All endpoints with DB access
```

### Endpoint Discovery from Code

Look for route definitions:
```python
# FastAPI
@router.get("/users/{user_id}")
@app.post("/api/v1/items")

# Flask
@app.route("/users", methods=["GET", "POST"])
@blueprint.route("/items/<id>")

# Express
router.get("/api/users", ...)
app.post("/api/items", ...)
```

## Priority Scoring

Calculate priority (0-100) for each endpoint:

| Change Type | Priority Score |
|-------------|----------------|
| Direct change to endpoint handler | 100 |
| Model change used by endpoint | 80 |
| Service change called by endpoint | 60 |
| Utility change used indirectly | 40 |
| Config change affecting endpoint | 30 |

### Priority Modifiers

- **Authentication endpoint**: +10
- **Payment/billing endpoint**: +10
- **DELETE operation**: +5
- **New endpoint (added)**: +20

## Regression Suite Selection

Based on priority scores:

```python
must_test = []    # priority >= 80
should_test = []  # priority >= 50
may_skip = []     # priority < 50

for endpoint, priority in sorted_endpoints:
    if priority >= 80:
        must_test.append(endpoint)
    elif priority >= 50:
        should_test.append(endpoint)
    else:
        may_skip.append(endpoint)
```

## Output Format

```json
{
  "agent": "regression_scanner",
  "git_info": {
    "base_branch": "main",
    "head_commit": "abc123",
    "is_dirty": false,
    "warnings": []
  },
  "files_analyzed": 12,
  "endpoints_affected": 5,
  "change_categories": {
    "api_routes": ["src/api/users.py"],
    "models": ["src/models/user.py"],
    "services": [],
    "utilities": ["src/utils/validation.py"],
    "config": []
  },
  "impact_map": [
    {
      "file": "src/api/users.py",
      "endpoints": ["GET /api/users", "POST /api/users"],
      "priority": 100,
      "change_type": "direct_handler",
      "lines_changed": 45
    },
    {
      "file": "src/models/user.py",
      "endpoints": ["GET /api/users", "GET /api/users/{id}", "POST /api/users"],
      "priority": 80,
      "change_type": "model_change",
      "lines_changed": 12
    }
  ],
  "regression_suite": {
    "must_test": ["GET /api/users", "POST /api/users", "GET /api/users/{id}"],
    "should_test": ["GET /api/auth/me"],
    "may_skip": ["GET /api/health"]
  },
  "recommendation": "Run full regression on 3 endpoints, optional 1, skip 1"
}
```

## Dependency Tracing

When a utility or model changes, trace its usage:

```bash
# Find all files importing the changed module
grep -r "from models.user import" --include="*.py"
grep -r "import.*User" --include="*.py"
```

Then map those files to their endpoints.

## Risk Escalation

Flag high-risk changes:
- Authentication/authorization logic
- Payment processing
- Data encryption
- SQL queries (potential injection)
- File operations (potential path traversal)

For high-risk changes, recommend DEEP testing depth.

