VCP Test Plan
Generate a comprehensive test plan for a specific file or module.
Step 1: Resolve Config
- Read
.vcp/config.json from the project root. Extract the pluginRoot field.
- If
.vcp/config.json does not exist or pluginRoot is missing: Stop and tell the user: "No VCP configuration found. Run /vcp-init to configure VCP for this project."
- Validate
pluginRoot: The path must be absolute, contain /.claude/ (or \.claude\ on Windows) as a path segment, and contain only safe path characters (letters, digits, /, \, -, _, ., :, and spaces). Reject any path with shell metacharacters (;, &, |, $, `, (, ), {, }, <, >, !, ~, #, *, ?, [, ], ', "). If validation fails, stop and tell the user: "Invalid pluginRoot — must be within ~/.claude/ and contain no shell metacharacters. Run /vcp-init to fix." Also verify the file <pluginRoot>/lib/vcp-context-core.ts exists using Glob. If it does not exist, stop and tell the user: "pluginRoot points to an invalid VCP installation. Run /vcp-init to fix."
- Run the config resolution script via Bash:
bun "<pluginRoot>/lib/resolve-config.ts" "<project-root>"
- Parse the JSON output. It contains:
applicableStandards, ignoredRules, severity, exclude.
Step 2: Fetch Applicable Standards
From the applicableStandards array in the resolved config, keep only entries where:
id is core-testing, OR
id is core-error-handling
For each selected standard, use WebFetch to fetch its content from:
{entry.url}
Extract the Rules section and the Patterns section from each fetched standard.
Step 4: Analyze Target Code
Target path: $ARGUMENTS. If not provided, ask the user which file or module to generate a test plan for.
Read the target code. Read the file(s) at the specified path.
Identify test-relevant elements:
- Entry points — Exported functions, public methods, API endpoints, route handlers, CLI commands
- External dependencies — HTTP clients, database connections, file system access, message queues, third-party SDKs, system clock
- Validation rules — Input validation, type checks, authorization checks, business rule enforcement
- Error conditions — Operations that can fail (network, parsing, I/O), explicit error throws, try/catch blocks
- State transitions — Functions that change state (database writes, cache updates, session changes, queue operations)
Identify the testing framework in use by checking:
package.json for jest, vitest, mocha, ava, etc.
pyproject.toml/setup.cfg for pytest, unittest
go.mod for testing package usage
- Existing test files for import patterns
Step 5: Generate Test Plan
Output a structured test plan following VCP testing standards.
### VCP Test Plan — `[file path]`
**Standards:** core-testing, core-error-handling
**Testing framework:** [detected framework]
#### Summary
- **Entry points:** N functions/methods
- **External dependencies:** [list]
- **Estimated tests:** N unit + M integration + P edge cases
---
#### Mock Guidance
**Mock these** (external boundaries):
- `PaymentGateway.charge()` — External payment API
- `db.query()` — Database connection
- `fetch()` / HTTP client — External API calls
**Do NOT mock these** (internal logic — test through them):
- `PriceCalculator.calculate()` — Internal business logic
- `OrderValidator.validate()` — Internal validation
- `formatCurrency()` — Internal utility
---
#### Unit Tests
##### `createOrder(items, userId)` — line 25
| # | Test Case | Input | Expected Output |
|---|-----------|-------|-----------------|
| 1 | Creates order with valid items | `[{id: 1, qty: 2}], "user-1"` | Order object with correct total |
| 2 | Rejects empty items array | `[], "user-1"` | Throws `ValidationError("items required")` |
| 3 | Rejects negative quantity | `[{id: 1, qty: -1}]` | Throws `ValidationError("quantity must be positive")` |
| 4 | Handles single item | `[{id: 1, qty: 1}]` | Order with total = item price |
| 5 | Handles maximum quantity | `[{id: 1, qty: 999999}]` | Order or appropriate limit error |
##### `processPayment(orderId)` — line 58
...
---
#### Integration Tests
| # | Test Case | Components | What It Verifies |
|---|-----------|------------|------------------|
| 1 | Full order flow | createOrder → processPayment → sendConfirmation | End-to-end order creation with mocked payment gateway |
| 2 | Payment failure rollback | createOrder → processPayment (fails) | Order status reverted, no charge persisted |
---
#### Edge Cases Checklist
- [ ] Null/undefined inputs for each function parameter
- [ ] Empty strings and empty arrays
- [ ] Zero and negative numeric values
- [ ] Boundary values (max int, max string length)
- [ ] Unicode and special characters in string inputs
- [ ] Concurrent access (if applicable)
- [ ] Network timeout on external calls
- [ ] Malformed response from external APIs
- [ ] Database connection failure during transaction
---
#### Error Path Tests
| # | Function | Error Condition | Expected Behavior |
|---|----------|-----------------|-------------------|
| 1 | `processPayment` | Payment gateway returns 500 | Throws `PaymentError`, order unchanged |
| 2 | `processPayment` | Payment gateway timeout | Throws `TimeoutError` after configured limit |
| 3 | `createOrder` | Database write fails | Transaction rolled back, throws `DatabaseError` |
If the target file has no testable functions (e.g., pure configuration, type definitions): "No testable functions found in [path]. This file contains [types/config/constants] and does not require a dedicated test plan."
1---2name: vcp-test-plan3description: Generate a test plan for specific code based on VCP testing standards. Produces unit tests, integration tests, edge cases, and mock guidance.4---5
6# VCP Test Plan
7
8Generate a comprehensive test plan for a specific file or module.
9
10## Step 1: Resolve Config
11
121. Read `.vcp/config.json` from the project root. Extract the `pluginRoot` field.
132. **If `.vcp/config.json` does not exist or `pluginRoot` is missing:** Stop and tell the user: "No VCP configuration found. Run `/vcp-init` to configure VCP for this project."
143. **Validate `pluginRoot`:** The path must be absolute, contain `/.claude/` (or `\.claude\` on Windows) as a path segment, and contain only safe path characters (letters, digits, `/`, `\`, `-`, `_`, `.`, `:`, and spaces). Reject any path with shell metacharacters (`;`, `&`, `|`, `$`, `` ` ``, `(`, `)`, `{`, `}`, `<`, `>`, `!`, `~`, `#`, `*`, `?`, `[`, `]`, `'`, `"`). If validation fails, stop and tell the user: "Invalid pluginRoot — must be within ~/.claude/ and contain no shell metacharacters. Run `/vcp-init` to fix." Also verify the file `<pluginRoot>/lib/vcp-context-core.ts` exists using Glob. If it does not exist, stop and tell the user: "pluginRoot points to an invalid VCP installation. Run `/vcp-init` to fix."
154. Run the config resolution script via Bash:
16 ```bash
17 bun "<pluginRoot>/lib/resolve-config.ts" "<project-root>"
18 ```
195. Parse the JSON output. It contains: `applicableStandards`, `ignoredRules`, `severity`, `exclude`.
20
21## Step 2: Fetch Applicable Standards
22
23From the `applicableStandards` array in the resolved config, keep only entries where:
24- `id` is `core-testing`, OR
25- `id` is `core-error-handling`
26
27For each selected standard, use WebFetch to fetch its content from:
28```
29{entry.url}
30```
31
32Extract the **Rules** section and the **Patterns** section from each fetched standard.
33
34## Step 4: Analyze Target Code
35
36**Target path:** `$ARGUMENTS`. If not provided, ask the user which file or module to generate a test plan for.
37
381. **Read the target code.** Read the file(s) at the specified path.
39
402. **Identify test-relevant elements:**
41 - **Entry points** — Exported functions, public methods, API endpoints, route handlers, CLI commands
42 - **External dependencies** — HTTP clients, database connections, file system access, message queues, third-party SDKs, system clock
43 - **Validation rules** — Input validation, type checks, authorization checks, business rule enforcement
44 - **Error conditions** — Operations that can fail (network, parsing, I/O), explicit error throws, try/catch blocks
45 - **State transitions** — Functions that change state (database writes, cache updates, session changes, queue operations)
46
473. **Identify the testing framework** in use by checking:
48 - `package.json` for `jest`, `vitest`, `mocha`, `ava`, etc.
49 - `pyproject.toml`/`setup.cfg` for `pytest`, `unittest`
50 - `go.mod` for `testing` package usage
51 - Existing test files for import patterns
52
53## Step 5: Generate Test Plan
54
55Output a structured test plan following VCP testing standards.
56
57```
58### VCP Test Plan — `[file path]`
59
60**Standards:** core-testing, core-error-handling
61**Testing framework:** [detected framework]
62
63#### Summary
64
65- **Entry points:** N functions/methods
66- **External dependencies:** [list]
67- **Estimated tests:** N unit + M integration + P edge cases
68
69---
70
71#### Mock Guidance
72
73**Mock these** (external boundaries):
74- `PaymentGateway.charge()` — External payment API
75- `db.query()` — Database connection
76- `fetch()` / HTTP client — External API calls
77
78**Do NOT mock these** (internal logic — test through them):
79- `PriceCalculator.calculate()` — Internal business logic
80- `OrderValidator.validate()` — Internal validation
81- `formatCurrency()` — Internal utility
82
83---
84
85#### Unit Tests
86
87##### `createOrder(items, userId)` — line 25
88
89| # | Test Case | Input | Expected Output |
90|---|-----------|-------|-----------------|
91| 1 | Creates order with valid items | `[{id: 1, qty: 2}], "user-1"` | Order object with correct total |
92| 2 | Rejects empty items array | `[], "user-1"` | Throws `ValidationError("items required")` |
93| 3 | Rejects negative quantity | `[{id: 1, qty: -1}]` | Throws `ValidationError("quantity must be positive")` |
94| 4 | Handles single item | `[{id: 1, qty: 1}]` | Order with total = item price |
95| 5 | Handles maximum quantity | `[{id: 1, qty: 999999}]` | Order or appropriate limit error |
96
97##### `processPayment(orderId)` — line 58
98
99...
100
101---
102
103#### Integration Tests
104
105| # | Test Case | Components | What It Verifies |
106|---|-----------|------------|------------------|
107| 1 | Full order flow | createOrder → processPayment → sendConfirmation | End-to-end order creation with mocked payment gateway |
108| 2 | Payment failure rollback | createOrder → processPayment (fails) | Order status reverted, no charge persisted |
109
110---
111
112#### Edge Cases Checklist
113
114- [ ] Null/undefined inputs for each function parameter
115- [ ] Empty strings and empty arrays
116- [ ] Zero and negative numeric values
117- [ ] Boundary values (max int, max string length)
118- [ ] Unicode and special characters in string inputs
119- [ ] Concurrent access (if applicable)
120- [ ] Network timeout on external calls
121- [ ] Malformed response from external APIs
122- [ ] Database connection failure during transaction
123
124---
125
126#### Error Path Tests
127
128| # | Function | Error Condition | Expected Behavior |
129|---|----------|-----------------|-------------------|
130| 1 | `processPayment` | Payment gateway returns 500 | Throws `PaymentError`, order unchanged |
131| 2 | `processPayment` | Payment gateway timeout | Throws `TimeoutError` after configured limit |
132| 3 | `createOrder` | Database write fails | Transaction rolled back, throws `DatabaseError` |
133```
134
135If the target file has no testable functions (e.g., pure configuration, type definitions): **"No testable functions found in [path]. This file contains [types/config/constants] and does not require a dedicated test plan."**