## Target Filtering Strategy

> This file defines the orchestration workflow for Stage 1 — confirming the output directory, acquiring scan targets, and saving the analysis draft.

### 1. Confirm Output Directory

1. Ask the user to confirm the output directory (default: `code-review_result/`)
2. If the output directory already exists, ask the user whether to rename for backup or delete it directly (default: backup)
3. Create the output directory

All intermediate drafts and final reports from subsequent stages will be written to this directory. Record the skill root path as `<skill-root>`; all reference paths in subsequent subtask prompts are based on this directory.

### 2. Acquire Scan Targets

The following three modes are supported:

**Mode 1: Branch Scan** (default) — the user provides source branch and target branch names:
```bash
git diff <target_branch>..<source_branch> --name-only --diff-filter=AM
```

**Mode 2: File Scan** — the user provides file paths, supporting `:start_line:line_count`:
- `src/app.ts`
- `src/app.ts:10:50` (starting from line 10, scanning 50 lines)

**Mode 3: Directory Scan** — the user provides a directory path, recursively scanning all non-empty files.

**Scan Mode Detection Rules** (auto-detected based on user-provided content):
- Contains two branch names → Branch Scan
- Contains file paths (with extensions) → File Scan
- Contains directory paths → Directory Scan
- When detection is not possible, ask the user to confirm

### 3. Project Environment Identification

1. Identify the programming language, type system (static/dynamic), and memory management model (manual: C/C++/Rust; automatic: Java/JS/Python/Go)
2. Read build configuration files (`package.json`, `pom.xml`, `go.mod`) to identify frameworks and key dependencies
3. Identify API frameworks (Express/FastAPI/Spring/Gin, etc.) and authentication mechanisms (JWT/Session/OAuth, etc.)
4. Identify database access patterns (ORM / Raw Query / Query Builder)

### 4. Save Scan Analysis Draft

Write to `<output_dir>/.draft-01-change-analysis.md`:

```
## Review Scope
- Scan mode: ...
- Scan target: ...
(Branch scan mode also includes source branch, target branch, MR URL)

## Project Environment
- **Language/Type System**: ... (static / dynamic)
- **Memory Management Model**: Manual / Automatic
- **Framework**: ...
- **API Framework**: ...
- **Authentication Mechanism**: ...
- **Database Access**: ORM / Raw Query / Query Builder

## Scan File List
- file1.ts
- file2.ts
...
```
