Skip to content

Commit b7d9fad

Browse files
committed
fix: add p-4 prefix expansion and deduplicate class name regex
1 parent 1dd55a9 commit b7d9fad

File tree

4 files changed

+62
-16
lines changed

4 files changed

+62
-16
lines changed

.claude/skills/tw-mcp-critical-review/SKILL.md

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,73 @@ Run a comprehensive review using multiple specialist agents in parallel.
2121

2222
2. **Collect results** from all 4 agents.
2323

24-
3. **Produce consolidated summary:**
24+
3. **Produce consolidated summary** (see format below).
25+
26+
## Agent Prompt Rules
27+
28+
**CRITICAL: Include these rules in EVERY agent prompt to prevent noise.**
29+
30+
Each agent prompt MUST include the following section verbatim:
31+
32+
```
33+
## What to Report
34+
35+
Only report issues that meet ALL of these criteria:
36+
1. **Demonstrably wrong** — you can show it produces incorrect behavior, crashes, data loss, or security vulnerability
37+
2. **Reproducible** — you can describe concrete steps or inputs that trigger the issue
38+
3. **Not a trade-off** — the current approach was not an intentional design choice with documented rationale
39+
40+
## What NOT to Report
41+
42+
Do NOT report any of the following. These are explicitly banned:
43+
- "Consider adding..." / "Could be improved by..." — speculative improvements
44+
- Performance optimizations for code that handles < 10,000 items (premature optimization)
45+
- Missing tests for private/internal functions — only flag missing tests for PUBLIC API
46+
- "This could break if..." with hypothetical future scenarios that don't exist today
47+
- Code style preferences already handled by the project's linter (Biome)
48+
- Suggesting abstractions, wrappers, or classes for code that works fine as-is
49+
- Duplicated findings from previous review rounds that were evaluated and accepted
50+
- "Add a comment explaining..." — if the code is clear, it doesn't need a comment
51+
- Alternative approaches that are equally valid but not better ("you could also do X")
52+
- Module-level state that is intentional and correctly managed (e.g., caches, singletons)
53+
- Missing error handling for errors that cannot occur in practice
54+
55+
## Severity Calibration
56+
57+
- **CRITICAL**: Currently broken in production. Data loss, security hole, crash. Must have reproduction steps.
58+
- **MAJOR**: Demonstrable bug or correctness issue with concrete example. NOT "this might cause problems someday."
59+
- **MINOR**: Real code smell with a clear fix, NOT a suggestion or preference.
60+
61+
## Hard Limits
62+
63+
- Maximum 3 MAJOR issues per agent. If you find more, keep only the top 3 by impact.
64+
- Maximum 5 MINOR issues per agent. If you find more, keep only the top 5.
65+
- If you find 0 issues, return APPROVE with "No issues found." Do NOT invent issues to fill the template.
66+
- It is BETTER to return APPROVE than to pad findings with noise.
67+
```
68+
69+
## Consolidated Summary Format
2570

2671
```
2772
## Critical Review Summary
2873
2974
### Architecture: [ALIGNED / DRIFT DETECTED]
30-
31-
[Key findings from ts-architect]
75+
[Only genuine architectural misalignment]
3276
3377
### Code Quality: [APPROVE / REQUEST CHANGES]
34-
35-
[Key findings from ts-code-reviewer]
78+
[Only demonstrable bugs or correctness issues]
3679
3780
### Test Coverage: [SUFFICIENT / GAPS FOUND]
38-
39-
[Key findings from ts-qa-developer]
81+
[Only missing tests for public API with real risk]
4082
4183
### Search Quality: [ACCEPTABLE / NEEDS TUNING]
42-
43-
[Key findings from search quality check]
84+
[Only measurable search quality problems]
4485
4586
### Blockers
46-
47-
[List any BLOCKER-severity issues]
87+
[List any CRITICAL-severity issues, or "None"]
4888
4989
### Action Items
50-
51-
[Prioritized list of changes needed]
90+
[Deduplicated, prioritized list — max 5 items total across all agents]
5291
```
5392

5493
## Success Criteria

src/storage/search.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Embedder } from "../pipeline/embedder.js";
22
import type { TailwindVersion } from "../utils/config.js";
3-
import { expandQuery } from "../utils/query-expansion.js";
3+
import { TAILWIND_CLASS_RE, expandQuery } from "../utils/query-expansion.js";
44
import { cosineSimilarity } from "../utils/similarity.js";
55
import { type ChunkRow, type Database, blobToEmbedding } from "./database.js";
66

@@ -125,7 +125,8 @@ export async function hybridSearch(
125125
]);
126126

127127
// Boost keyword weight when query contains Tailwind class names (e.g., text-lg, pt-6, -mx-4)
128-
const hasClassNames = /\b-?[a-z]+(?:-[a-z0-9]+)+\b/.test(query);
128+
const hasClassNames = TAILWIND_CLASS_RE.test(query);
129+
TAILWIND_CLASS_RE.lastIndex = 0; // Reset global regex state after .test()
129130
const weights: FusionWeights = hasClassNames
130131
? { semantic: 1.0, keyword: 1.5 }
131132
: { semantic: 1.0, keyword: 1.0 };

src/utils/query-expansion.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
/** Regex to detect Tailwind class names: hyphenated lowercase tokens like text-lg, grid-cols-3, -mx-4 */
10-
const TAILWIND_CLASS_RE = /\b-?[a-z]+(?:-[a-z0-9]+)+\b/g;
10+
export const TAILWIND_CLASS_RE = /\b-?[a-z]+(?:-[a-z0-9]+)+\b/g;
1111

1212
/** Font size suffixes used by Tailwind's text-{size} utilities */
1313
const TEXT_SIZE_RE = /^text-(xs|sm|base|lg|xl|\d+xl)$/;
@@ -50,6 +50,7 @@ const PREFIX_MAP = new Map<string, string>([
5050

5151
// ── Single-segment prefixes ────────────────────────────────────
5252
// Spacing
53+
["p", "padding"],
5354
["px", "padding"],
5455
["py", "padding"],
5556
["pt", "padding"],

test/unit/query-expansion.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ describe("Query Expansion", () => {
4444
expect(result).toContain("padding");
4545
});
4646

47+
it("expands p-4 to include padding", () => {
48+
const result = expandQuery("p-4 class");
49+
expect(result).toContain("padding");
50+
});
51+
4752
// ── Grid expansions ──────────────────────────────────────────
4853
it("expands grid-cols-3 to include grid template columns", () => {
4954
const result = expandQuery("grid-cols-3 tailwind grid");

0 commit comments

Comments
 (0)