Skip to content

Commit 1fe67ea

Browse files
ashwin2002claude
andcommitted
Add review-guidelines skill for structured code review process
Adds a new skill at agents/skills/review-guidelines/SKILL.md with an 8-step review checklist covering correctness, TAF pattern compliance, conf file validation, security, code quality (trailing whitespace, debug prints), and severity-tiered output (BLOCKER/MAJOR/MINOR/NIT). Wired into .claude/skills/, .factory/skills/, settings.json, and AGENTS.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Change-Id: I8627176fa1685007e17c41cc5ff69e1c56594943 Reviewed-on: https://review.couchbase.org/c/TAF/+/245130 Reviewed-by: Bharath G P <bharath.gp@couchbase.com> Tested-by: Ashwin <ashwin.govindarajulu@couchbase.com>
1 parent dcf2f58 commit 1fe67ea

5 files changed

Lines changed: 255 additions & 0 deletions

File tree

.claude/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"name": "test_debugging",
1010
"description": "Given a scenario or test logs, maps to the actual code, debugs the failure, and proposes a concrete fix. Resolves which layer owns the failure, reads the source, diagnoses root cause, and provides before/after fix.",
1111
"path": "agents/skills/test_debugging.md"
12+
},
13+
{
14+
"name": "review-guidelines",
15+
"description": "Structured code review process for TAF changes. Use when asked to review a PR, diff, branch, or set of changed files — covers correctness, TAF pattern compliance, configuration validity, security, and produces prioritized BLOCKER/MAJOR/MINOR/NIT comments.",
16+
"path": "agents/skills/review-guidelines/SKILL.md"
1217
}
1318
]
1419
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@agents/skills/review-guidelines/SKILL.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@agents/skills/review-guidelines/SKILL.md

agents/skills/AGENTS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ Comprehensive code map and flow reference for `pytests/upgrade/`. Covers class h
6060

6161
---
6262

63+
### review-guidelines
64+
Structured code review process for TAF changes. Produces prioritized BLOCKER/MAJOR/MINOR/NIT comments across correctness, TAF patterns, configuration, security, and code quality.
65+
66+
**Usage:** When asked to review a PR, diff, branch, or changed files — "review these changes", "check my changes before I commit".
67+
68+
**Key features:**
69+
- 8-step review process: scope → correctness → TAF patterns → config → security → quality → docs → output
70+
- TAF-specific checks: base class, TestInputSingleton params, tearDown cleanup, submodule boundaries
71+
- Enforces `.conf` entry for every new `test_*` method added under `pytests/`
72+
- Catches leftover debug prints (`print`, `pdb`, `breakpoint`) and trailing whitespace
73+
- Severity-tiered output format (BLOCKER / MAJOR / MINOR / NIT) with file:line citations
74+
- Quick reference checklist for full coverage at a glance
75+
76+
**File:** `agents/skills/review-guidelines/SKILL.md`
77+
78+
---
79+
6380
## Adding a New Skill
6481

6582
1. Create `agents/skills/<name>.md` with YAML frontmatter:
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
---
2+
name: review-guidelines
3+
description: >-
4+
Structured code review process for TAF changes. Provides step-by-step
5+
guidance for reviewing Python test code, configuration files, and library
6+
changes. Use when asked to review a PR, diff, or set of changed files in TAF.
7+
---
8+
9+
# Agent Review Skill
10+
11+
## Purpose
12+
13+
Provide a structured, repeatable code review process tailored to TAF conventions.
14+
Covers correctness, test quality, framework patterns, configuration validity, and
15+
security — producing actionable, prioritized review comments.
16+
17+
---
18+
19+
## When to Use
20+
21+
- "Review these changes"
22+
- "Check my changes before I commit"
23+
- "What's wrong with this code?"
24+
- Reviewing any changed `.py`, `.conf`, `.ini`, or `AGENTS.md` file in TAF
25+
26+
---
27+
28+
## Review Process
29+
30+
### Step 1 — Understand the Scope
31+
32+
Before reading any code:
33+
34+
1. Run `git diff --stat` (or inspect the provided diff) to list changed files.
35+
2. Group files by layer:
36+
- **Tests**`pytests/**/*.py`
37+
- **Libraries**`lib/**/*.py`, `couchbase_utils/**/*.py`, `platform_utils/**/*.py`
38+
- **Configuration**`conf/**/*.conf`, `*.ini`
39+
- **Documentation**`agents/**/*.md`, `docs/**/*.md`, `AGENTS.md`
40+
3. Read the relevant `AGENTS.md` for each directory touched before opening `.py` files.
41+
4. State the summary: what feature/fix this change appears to implement.
42+
43+
---
44+
45+
### Step 2 — Correctness Review
46+
47+
For each changed `.py` file:
48+
49+
**Logic & Semantics**
50+
- [ ] Does the code do what the commit message / PR description claims?
51+
- [ ] Are all edge cases handled (empty collections, zero counts, `None` returns)?
52+
- [ ] Are conditional branches exhaustive — no implicit fall-throughs?
53+
- [ ] Are loop bounds correct (off-by-one, infinite loop risk)?
54+
55+
**Error Handling**
56+
- [ ] Exceptions are caught at the right level — not swallowed silently.
57+
- [ ] Timeouts and retries are bounded; no unbounded `while True` without exit.
58+
- [ ] Failures surface a clear error message rather than a cryptic stack trace.
59+
60+
**Data Integrity**
61+
- [ ] No mutable default arguments (`def foo(x=[])`).
62+
- [ ] Shared state (class variables, globals) is not accidentally mutated.
63+
- [ ] Thread/task safety for anything running in parallel task workers.
64+
65+
---
66+
67+
### Step 3 — TAF Pattern Compliance
68+
69+
Check against TAF conventions (from `AGENTS.md`):
70+
71+
**Naming**
72+
- [ ] Functions and variables: `snake_case`
73+
- [ ] Classes: `PascalCase`
74+
- [ ] Constants: `UPPER_SNAKE_CASE`
75+
- [ ] Test methods: `test_` prefix
76+
- [ ] Private helpers: `_leading_underscore`
77+
- Exception: `setUp`, `tearDown`, `setUpClass`, `tearDownClass` are allowed.
78+
79+
**Test Structure**
80+
- [ ] Test class inherits from the correct base (`OnPremBaseTest`, `ColumnarBaseTest`, etc.) based on `runtype`.
81+
- [ ] Parameters accessed via `TestInputSingleton.input.param("name", default)` — no hard-coded values.
82+
- [ ] `tearDown` cleans up all resources created in the test.
83+
- [ ] No `print()` statements — use the framework logger.
84+
- [ ] No hard-coded cluster IPs, credentials, or cloud identifiers.
85+
86+
**Document Loading**
87+
- [ ] If `load_docs_using` is referenced, valid values are `default_loader`, `sirius_java_sdk`, `sirius_go_sdk`.
88+
- [ ] `sirius_java_sdk` usage requires `--launch_java_doc_loader` flag documentation.
89+
90+
**Submodule Boundaries**
91+
- [ ] No edits to `DocLoader/`, `lib/capellaAPI/`, or `sirius/` — these are maintained separately.
92+
93+
---
94+
95+
### Step 4 — Configuration File Review (`.conf` / `.ini`)
96+
97+
For each changed `conf/**/*.conf`:
98+
99+
- [ ] Each test entry follows the format: `module.class.test_method,param1=value1`
100+
- [ ] No duplicate test entries within the same file.
101+
- [ ] Parameter values are valid (no stray spaces, correct types).
102+
- [ ] If a new `test_*` method was added under `pytests/`, a corresponding `.conf` entry exists that exercises it.
103+
- [ ] If a test method was removed from `.py`, its `.conf` entry is also removed.
104+
- [ ] `.conf` entry for a new test is in the correct component conf file (matches the module path of the test class).
105+
106+
For changed `*.ini` files:
107+
- [ ] No credentials or secrets committed.
108+
- [ ] Node topology is consistent (IP counts match role assignments).
109+
110+
---
111+
112+
### Step 5 — Security Review
113+
114+
- [ ] No hard-coded passwords, API keys, tokens, or secrets anywhere.
115+
- [ ] No `shell=True` in `subprocess` calls with user-controlled input (command injection risk).
116+
- [ ] No `eval()` or `exec()` on untrusted data.
117+
- [ ] SSH commands use paramiko abstractions from `platform_utils/ssh_util/` — not raw shell concat.
118+
- [ ] REST API calls use existing `cb_server_rest_util` wrappers; no ad-hoc credential embedding in URLs.
119+
120+
---
121+
122+
### Step 6 — Code Quality & Maintainability
123+
124+
**Readability**
125+
- [ ] Comments explain *why*, not *what* — no comment restates the code.
126+
- [ ] No commented-out dead code blocks left in.
127+
- [ ] No TODO/FIXME/HACK left without a linked ticket or rationale.
128+
- [ ] No trailing whitespace at end of any line (`grep -rn ' $' <file>` to verify).
129+
- [ ] No leftover debug statements — `print()`, `pdb.set_trace()`, `breakpoint()`, or temporary `logging.debug("here")`-style breadcrumbs (`grep -rn 'print\|pdb\|breakpoint' pytests/` to scan).
130+
131+
**Duplication**
132+
- [ ] No copy-paste of existing utility methods — use `couchbase_utils/` helpers.
133+
- [ ] No re-implemented logic already in the base test class.
134+
- [ ] No repeated code blocks — extract to a shared helper in the base class or `couchbase_utils/`.
135+
136+
**Size**
137+
- [ ] Functions are focused — no method doing 5 unrelated things.
138+
- [ ] Test methods test one scenario — split combined tests that assert unrelated outcomes.
139+
140+
**Imports**
141+
- [ ] No unused imports.
142+
- [ ] Imports follow: stdlib → third-party → local framework.
143+
- [ ] No circular import dependencies — if module A imports B and B imports A, refactor shared logic into a third module (`pip install importlab` or `python -m py_compile` to surface cycles).
144+
145+
---
146+
147+
### Step 7 — Documentation & AGENTS.md
148+
149+
- [ ] If a new class or public method was added, its `AGENTS.md` entry is updated (if the directory has one).
150+
- [ ] If a method was renamed or removed, all `AGENTS.md` references are updated.
151+
- [ ] Docstrings (if present) are accurate — not copy-pasted from a different method.
152+
- [ ] `conf/` changes are reflected in the test class's `AGENTS.md` parameter table (if one exists).
153+
154+
---
155+
156+
### Step 8 — Produce Review Output
157+
158+
Structure comments by severity:
159+
160+
| Level | When to use |
161+
|-------|-------------|
162+
| **BLOCKER** | Bug, security issue, data loss, or broken test — must fix before merge |
163+
| **MAJOR** | Violates TAF pattern, missing cleanup, wrong base class — fix strongly recommended |
164+
| **MINOR** | Style, naming, readability — fix preferred but not blocking |
165+
| **NIT** | Cosmetic (whitespace, comment wording) — optional |
166+
167+
**Comment format:**
168+
169+
```
170+
[BLOCKER] pytests/storage/fusion/fusion_base.py:142
171+
tearDown does not call super().tearDown(). Cluster cleanup will be skipped on failure.
172+
Fix: add `super().tearDown()` as the last line.
173+
174+
[MAJOR] conf/fusion/fusion_sanity.conf:17
175+
Test entry references `fusion_sanity.FusionSanity.test_foo` but that method does not
176+
exist in the class. Will silently skip at runtime.
177+
Fix: correct method name to `test_foo_bar` or remove the entry.
178+
179+
[MINOR] pytests/storage/fusion/fusion_sync.py:88
180+
Variable `bucketList` should be `bucket_list` (PEP8 snake_case).
181+
182+
[NIT] pytests/storage/fusion/fusion_sync.py:92
183+
Comment "# loop over buckets" restates the code. Remove.
184+
```
185+
186+
End with a one-line summary:
187+
```
188+
Overall: N blockers, N major, N minor, N nits. [Ready to merge / Needs fixes before merge.]
189+
```
190+
191+
---
192+
193+
## Quick Reference Checklist
194+
195+
```
196+
Scope
197+
[ ] Changed files identified and grouped by layer
198+
[ ] Relevant AGENTS.md files read before .py files
199+
200+
Correctness
201+
[ ] Logic matches intent
202+
[ ] Edge cases handled
203+
[ ] No silent exception swallowing
204+
205+
TAF Patterns
206+
[ ] Naming conventions followed
207+
[ ] Correct base class
208+
[ ] Parameters via TestInputSingleton
209+
[ ] tearDown cleans up resources
210+
[ ] No hard-coded credentials or IPs
211+
[ ] Submodule boundaries respected
212+
213+
Configuration
214+
[ ] Every new test_* method in pytests/ has a .conf entry
215+
[ ] .conf entries match actual test methods
216+
[ ] No duplicate entries
217+
218+
Security
219+
[ ] No secrets committed
220+
[ ] No shell injection vectors
221+
222+
Quality
223+
[ ] No dead code or stale comments
224+
[ ] No leftover debug prints (print, pdb, breakpoint)
225+
[ ] No trailing whitespace
226+
[ ] No duplicated utility logic
227+
[ ] Imports clean (no unused, no circular dependencies)
228+
229+
Documentation
230+
[ ] AGENTS.md updated if public API changed
231+
```

0 commit comments

Comments
 (0)