Skill: aposd-verifying-correctness
STOP - Before "Done"
Design quality ≠ correctness. Well-designed code can still have bugs, missing requirements, or safety issues.
Run ALL dimension checks before claiming done. "I think I covered everything" without explicit mapping is a red flag.
Dimension Detection & Checks
For each dimension: detect if it applies, then verify.
1. Requirements Coverage
Detect: Were requirements stated? (explicit list, user request, spec)
If YES, verify:
Red flag: "I think I covered everything" without explicit mapping
2. Concurrency Safety
Detect: Any of these present?
- Multiple threads/processes accessing same data
- Async/await patterns
- Shared mutable state (class attributes, globals)
- "Thread-safe" in requirements or docstring
- Web handlers, queue workers, background tasks
If YES, verify:
Red flag: "It's probably fine" or "Python GIL handles it"
3. Error Handling
Detect: Can any operation fail?
- I/O (file, network, database)
- External calls (APIs, subprocesses)
- Resource acquisition (memory, connections)
- User input processing
- Parsing/deserialization
If YES, verify:
Red flag: "Errors are rare" or "caller handles it" without checking caller
4. Resource Management
Detect: Does code acquire resources?
- File handles, sockets, connections
- Locks, semaphores
- Memory allocations (large buffers, caches)
- External service handles
- Background threads/processes
If YES, verify:
Red flag: "It cleans up eventually" or daemon threads without shutdown
5. Boundary Conditions
Detect: Does code handle variable-size input?
- Collections (lists, dicts, sets)
- Strings, byte arrays
- Numeric ranges
- Optional/nullable values
If YES, verify:
Red flag: "Nobody would pass that" or "that's an edge case"
6. Security (if applicable)
Detect: Does code handle untrusted input?
- User-provided data (forms, API requests)
- File contents from external sources
- URLs, paths, identifiers from users
- Data that becomes SQL, shell, HTML, or code
If YES, verify:
Red flag: "It's internal only" (internals get exposed)
Quick Checklist (Minimum)
Before "done", answer YES to all that apply:
| Dimension |
Detection Trigger |
Verified? |
| Requirements |
Requirements were stated |
[ ] Each mapped to code |
| Concurrency |
Shared state exists |
[ ] All access protected |
| Errors |
Operations can fail |
[ ] All failures handled |
| Resources |
Resources acquired |
[ ] All released (incl. errors) |
| Boundaries |
Variable-size input |
[ ] Edge cases handled |
| Security |
Untrusted input |
[ ] Input validated |
Anti-Rationalization Table
| Thought |
Reality |
| "Design is good, so it works" |
Design ≠ correctness. Check anyway. |
| "It's simple code" |
Simple code has bugs too. Check anyway. |
| "I'll add error handling later" |
Later = never. Check now. |
| "Edge cases are rare" |
Edge cases cause production incidents. |
| "It's not user-facing" |
Internal code gets exposed. Check anyway. |
| "Tests will catch it" |
Tests check what you wrote, not what you missed. |
Output Format
When verifying, output:
## Correctness Verification
### Requirements: [PASS/FAIL/N/A]
- Requirement 1 → implemented in X
- Requirement 2 → implemented in Y
### Concurrency: [PASS/FAIL/N/A]
- Shared state: [list]
- Protection: [how]
### Errors: [PASS/FAIL/N/A]
- Failure points: [list]
- Handling: [approach]
### Resources: [PASS/FAIL/N/A]
- Acquired: [list]
- Released: [how]
### Boundaries: [PASS/FAIL/N/A]
- Edge cases: [list]
- Handling: [approach]
### Security: [PASS/FAIL/N/A]
- Untrusted input: [list]
- Validation: [approach]
**Verdict:** [DONE / NOT DONE - list blockers]
Relationship to Other Skills
| Skill |
Focus |
When |
| aposd-designing-deep-modules |
Design quality |
FIRST—during design |
| aposd-maintaining-design-quality |
Design philosophy |
During modification |
| aposd-verifying-correctness |
Actual correctness |
BEFORE "done" |
| cc-quality-practices |
Testing/debugging |
Throughout |
Order: Design → Implement → Verify (this skill) → Done
Chain
| After |
Next |
| All dimensions pass |
Done (pre-commit gate) |
1---2name: aposd-verifying-correctness3description: Verify code correctness before claiming done or committing. Run 6-dimension checklist: requirements coverage, concurrency safety, error handling, resource management, boundary conditions, and security. Output PASS/FAIL per dimension with final DONE/NOT DONE verdict. Use after implementation as pre-commit gate. Triggers on: is it done, ready to commit, verify correctness, did I miss anything, pre-commit check.4---5
6# Skill: aposd-verifying-correctness
7
8## STOP - Before "Done"
9
10**Design quality ≠ correctness.** Well-designed code can still have bugs, missing requirements, or safety issues.
11
12**Run ALL dimension checks before claiming done.** "I think I covered everything" without explicit mapping is a red flag.
13
14---
15
16## Dimension Detection & Checks
17
18For each dimension: detect if it applies, then verify.
19
20---
21
22### 1. Requirements Coverage
23
24**Detect:** Were requirements stated? (explicit list, user request, spec)
25
26**If YES, verify:**
27- [ ] List each requirement explicitly
28- [ ] For each: point to code that implements it
29- [ ] Any requirement without code? → **Not done**
30- [ ] Any code without requirement? → Scope creep or missing requirement
31
32**Red flag:** "I think I covered everything" without explicit mapping
33
34---
35
36### 2. Concurrency Safety
37
38**Detect:** Any of these present?
39- Multiple threads/processes accessing same data
40- Async/await patterns
41- Shared mutable state (class attributes, globals)
42- "Thread-safe" in requirements or docstring
43- Web handlers, queue workers, background tasks
44
45**If YES, verify:**
46- [ ] All shared mutable state identified
47- [ ] Each access point protected (lock, atomic, queue, immutable)
48- [ ] No time-of-check to time-of-use (TOCTOU) gaps
49- [ ] Lock ordering consistent (if multiple locks)
50
51**Red flag:** "It's probably fine" or "Python GIL handles it"
52
53---
54
55### 3. Error Handling
56
57**Detect:** Can any operation fail?
58- I/O (file, network, database)
59- External calls (APIs, subprocesses)
60- Resource acquisition (memory, connections)
61- User input processing
62- Parsing/deserialization
63
64**If YES, verify:**
65- [ ] Each failure point has explicit handling OR propagates
66- [ ] No bare `except:` or `except Exception: pass`
67- [ ] Error messages actionable (what failed, why, how to fix)
68- [ ] Partial failures handled (rollback, cleanup, consistent state)
69
70**Red flag:** "Errors are rare" or "caller handles it" without checking caller
71
72---
73
74### 4. Resource Management
75
76**Detect:** Does code acquire resources?
77- File handles, sockets, connections
78- Locks, semaphores
79- Memory allocations (large buffers, caches)
80- External service handles
81- Background threads/processes
82
83**If YES, verify:**
84- [ ] Every acquire has corresponding release
85- [ ] Release happens in finally/context manager/destructor
86- [ ] Release happens on error paths too
87- [ ] No resource leaks on repeated calls
88- [ ] Bounded growth (caches have limits, queues have limits)
89
90**Red flag:** "It cleans up eventually" or daemon threads without shutdown
91
92---
93
94### 5. Boundary Conditions
95
96**Detect:** Does code handle variable-size input?
97- Collections (lists, dicts, sets)
98- Strings, byte arrays
99- Numeric ranges
100- Optional/nullable values
101
102**If YES, verify:**
103- [ ] Empty input: What happens with `[]`, `""`, `None`, `0`?
104- [ ] Single item: Edge case often different from N items
105- [ ] Maximum size: What if input is huge? Memory? Time?
106- [ ] Invalid values: Negative numbers, NaN, special characters?
107- [ ] Type boundaries: int overflow, float precision?
108
109**Red flag:** "Nobody would pass that" or "that's an edge case"
110
111---
112
113### 6. Security (if applicable)
114
115**Detect:** Does code handle untrusted input?
116- User-provided data (forms, API requests)
117- File contents from external sources
118- URLs, paths, identifiers from users
119- Data that becomes SQL, shell, HTML, or code
120
121**If YES, verify:**
122- [ ] Input validated before use
123- [ ] No string concatenation for SQL/shell/HTML (use parameterized)
124- [ ] Path traversal prevented (no `../` exploitation)
125- [ ] Secrets not logged or exposed in errors
126- [ ] Auth/authz checked before action, not after
127
128**Red flag:** "It's internal only" (internals get exposed)
129
130---
131
132## Quick Checklist (Minimum)
133
134Before "done", answer YES to all that apply:
135
136| Dimension | Detection Trigger | Verified? |
137|-----------|-------------------|-----------|
138| Requirements | Requirements were stated | [ ] Each mapped to code |
139| Concurrency | Shared state exists | [ ] All access protected |
140| Errors | Operations can fail | [ ] All failures handled |
141| Resources | Resources acquired | [ ] All released (incl. errors) |
142| Boundaries | Variable-size input | [ ] Edge cases handled |
143| Security | Untrusted input | [ ] Input validated |
144
145---
146
147## Anti-Rationalization Table
148
149| Thought | Reality |
150|---------|---------|
151| "Design is good, so it works" | Design ≠ correctness. Check anyway. |
152| "It's simple code" | Simple code has bugs too. Check anyway. |
153| "I'll add error handling later" | Later = never. Check now. |
154| "Edge cases are rare" | Edge cases cause production incidents. |
155| "It's not user-facing" | Internal code gets exposed. Check anyway. |
156| "Tests will catch it" | Tests check what you wrote, not what you missed. |
157
158---
159
160## Output Format
161
162When verifying, output:
163
164```
165## Correctness Verification
166
167### Requirements: [PASS/FAIL/N/A]
168- Requirement 1 → implemented in X
169- Requirement 2 → implemented in Y
170
171### Concurrency: [PASS/FAIL/N/A]
172- Shared state: [list]
173- Protection: [how]
174
175### Errors: [PASS/FAIL/N/A]
176- Failure points: [list]
177- Handling: [approach]
178
179### Resources: [PASS/FAIL/N/A]
180- Acquired: [list]
181- Released: [how]
182
183### Boundaries: [PASS/FAIL/N/A]
184- Edge cases: [list]
185- Handling: [approach]
186
187### Security: [PASS/FAIL/N/A]
188- Untrusted input: [list]
189- Validation: [approach]
190
191**Verdict:** [DONE / NOT DONE - list blockers]
192```
193
194---
195
196## Relationship to Other Skills
197
198| Skill | Focus | When |
199|-------|-------|------|
200| **aposd-designing-deep-modules** | Design quality | FIRST—during design |
201| **aposd-maintaining-design-quality** | Design philosophy | During modification |
202| **aposd-verifying-correctness** | Actual correctness | BEFORE "done" |
203| **cc-quality-practices** | Testing/debugging | Throughout |
204
205**Order:** Design → Implement → Verify (this skill) → Done
206
207
208---
209
210## Chain
211
212| After | Next |
213|-------|------|
214| All dimensions pass | Done (pre-commit gate) |