Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/agents/rule-discovery/designer.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ You will receive:
- Read `src/core/rules/` to understand rule structure
- Read `src/core/rules/rule-config.ts` for score/severity conventions
3. Design the rule:
- **Rule ID**: kebab-case, descriptive (e.g., `missing-component-description`)
- **Category**: existing (`structure | token | component | naming | behavior`) or propose a new category if none fits. New categories require justification.
- **Rule ID**: kebab-case, descriptive (e.g., `raw-value`)
- **Category**: existing (`pixel-critical | responsive-critical | code-quality | token-management | minor`) or propose a new category if none fits. New categories require justification.
- **Severity**: `blocking | risk | missing-info | suggestion`
- **Initial score**: based on estimated impact on implementation difficulty
- **Check logic**: what condition triggers the violation
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ body:
attributes:
label: Symptom
description: What's happening? Include error messages, wrong output, or unexpected behavior.
placeholder: "unnecessary-node scores -10 (blocking) but hidden layers don't block implementation"
placeholder: "raw-value scores -3 (missing-info) but tokenized fills are still flagged"
validations:
required: true
- type: textarea
Expand Down
56 changes: 19 additions & 37 deletions docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ canicode analyze <url> --config ./my-config.json
"excludeNodeTypes": ["VECTOR", "BOOLEAN_OPERATION", "SLICE"],
"excludeNodeNames": ["chatbot", "ad-banner", "custom-widget"],
"gridBase": 4,
"colorTolerance": 5,
"rules": {
"no-auto-layout": { "score": -15, "severity": "blocking", "enabled": true },
"raw-color": { "score": -12 },
"raw-value": { "score": -5 },
"default-name": { "enabled": false }
}
}
Expand All @@ -37,8 +36,7 @@ canicode analyze <url> --config ./my-config.json
|-------|------|---------|-------------|
| `excludeNodeTypes` | `string[]` | `[]` | Figma node types to skip entirely (node + children) |
| `excludeNodeNames` | `string[]` | `[]` | Name patterns to skip (case-insensitive word match) |
| `gridBase` | `number` | `4` | Spacing grid unit for `inconsistent-spacing` and `magic-number-spacing` |
| `colorTolerance` | `number` | `10` | Color difference tolerance for `multiple-fill-colors` |
| `gridBase` | `number` | `4` | Spacing grid unit for `irregular-spacing` |
| `rules` | `object` | — | Per-rule overrides (see below) |

### Node Exclusions
Expand Down Expand Up @@ -93,59 +91,44 @@ Override score, severity, or enable/disable individual rules:
### All Rule IDs

<!-- RULE_TABLE_START — auto-generated by scripts/sync-rule-docs.ts, do not edit manually -->
**Structure (9 rules)**
**Pixel Critical (3 rules)** — layout issues that directly affect pixel accuracy (ΔV ≥ 5%)

| Rule ID | Default Score | Default Severity |
|---------|--------------|-----------------|
| `no-auto-layout` | -10 | blocking |
| `absolute-position-in-auto-layout` | -7 | blocking |
| `fixed-size-in-auto-layout` | -3 | risk |
| `missing-size-constraint` | -3 | risk |
| `missing-responsive-behavior` | -3 | risk |
| `group-usage` | -5 | risk |
| `deep-nesting` | -4 | risk |
| `z-index-dependent-layout` | -5 | risk |
| `unnecessary-node` | -2 | suggestion |
| `non-layout-container` | -8 | blocking |

**Token (7 rules)**
**Responsive Critical (2 rules)** — size issues that break at different viewports (ΔV ≥ 15%)

| Rule ID | Default Score | Default Severity |
|---------|--------------|-----------------|
| `raw-color` | -2 | missing-info |
| `raw-font` | -4 | risk |
| `inconsistent-spacing` | -2 | missing-info |
| `magic-number-spacing` | -3 | risk |
| `raw-shadow` | -3 | missing-info |
| `raw-opacity` | -2 | missing-info |
| `multiple-fill-colors` | -3 | missing-info |
| `fixed-size-in-auto-layout` | -6 | risk |
| `missing-size-constraint` | -5 | risk |

**Component (4 rules)**
**Code Quality (4 rules)** — structural issues affecting code reuse (ΔV ≈ 0%, CSS classes -8~15)

| Rule ID | Default Score | Default Severity |
|---------|--------------|-----------------|
| `missing-component` | -7 | risk |
| `detached-instance` | -5 | risk |
| `missing-component-description` | -2 | missing-info |
| `detached-instance` | -4 | risk |
| `variant-structure-mismatch` | -4 | risk |
| `deep-nesting` | -3 | risk |

**Naming (5 rules)**
**Token Management (2 rules)** — raw values without design tokens

| Rule ID | Default Score | Default Severity |
|---------|--------------|-----------------|
| `default-name` | -2 | missing-info |
| `non-semantic-name` | -2 | missing-info |
| `inconsistent-naming-convention` | -2 | missing-info |
| `numeric-suffix-name` | -1 | suggestion |
| `too-long-name` | -1 | suggestion |
| `raw-value` | -3 | missing-info |
| `irregular-spacing` | -2 | missing-info |

**Behavior (4 rules)**
**Minor (3 rules)** — naming issues with negligible impact (ΔV < 2%)

| Rule ID | Default Score | Default Severity |
|---------|--------------|-----------------|
| `text-truncation-unhandled` | -5 | risk |
| `prototype-link-in-design` | -2 | missing-info |
| `overflow-behavior-unknown` | -3 | missing-info |
| `wrap-behavior-unknown` | -3 | missing-info |
| `default-name` | -1 | suggestion |
| `non-semantic-name` | -1 | suggestion |
| `inconsistent-naming-convention` | -1 | suggestion |
<!-- RULE_TABLE_END -->

### Example Configs
Expand All @@ -155,8 +138,8 @@ Override score, severity, or enable/disable individual rules:
{
"rules": {
"no-auto-layout": { "score": -15 },
"raw-color": { "score": -10, "severity": "blocking" },
"default-name": { "score": -8, "severity": "blocking" }
"raw-value": { "score": -5, "severity": "risk" },
"default-name": { "score": -3, "severity": "risk" }
}
}
```
Expand All @@ -178,7 +161,6 @@ Override score, severity, or enable/disable individual rules:
```json
{
"rules": {
"missing-responsive-behavior": { "score": -10, "severity": "blocking" },
"fixed-size-in-auto-layout": { "score": -8, "severity": "blocking" },
"no-auto-layout": { "score": -12 }
}
Expand Down
11 changes: 3 additions & 8 deletions examples/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@
"excludeNodeTypes": ["SLICE", "STICKY"],
"excludeNodeNames": ["chatbot", "ad-banner", "prototype", "wip"],
"gridBase": 4,
"colorTolerance": 5,
"rules": {
"no-auto-layout": {
"score": -15,
"severity": "blocking"
},
"raw-color": {
"score": -12,
"severity": "blocking"
"raw-value": {
"score": -3,
"severity": "missing-info"
},
"default-name": {
"enabled": false
},
"missing-responsive-behavior": {
"score": -8,
"severity": "blocking"
}
}
}
2 changes: 1 addition & 1 deletion src/agents/analysis-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function createMockIssue(overrides: {
definition: {
id: overrides.ruleId,
name: `Rule ${overrides.ruleId}`,
category: "structure",
category: "pixel-critical",
why: "test reason",
impact: "test impact",
fix: "test fix",
Expand Down
Loading
Loading