Skip to content

Commit ec68427

Browse files
author
Test User
committed
docs: update README and cross-file-validation with new features
- Add diff-aware linting section (--staged, --diff) - Add baseline support section (--baseline, --baseline-create) - Add canonical formatting section (cclint fmt) - Add circular dependency detection to cross-file validation - Update GitHub Actions example with Go setup - Update pre-commit hook to use --staged for speed
1 parent cdf466b commit ec68427

2 files changed

Lines changed: 133 additions & 10 deletions

File tree

README.md

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ cclint validates YAML frontmatter, checks structural patterns, and suggests impr
1010
- **YAML frontmatter parsing**: Validates required fields and data types
1111
- **CUE schema validation**: Embedded schemas for type-safe validation
1212
- **Quality scoring**: 0-100 scores with tier grading (A-F)
13-
- **Cross-file validation**: Detects missing skill references
13+
- **Cross-file validation**: Detects missing skill references and circular dependencies
14+
- **Diff-aware linting**: Lint only staged/changed files for fast pre-commit hooks
15+
- **Baseline support**: Gradual adoption for legacy projects with existing issues
16+
- **Canonical formatting**: `cclint fmt` for consistent component style
1417
- **Multiple output formats**: Console, JSON, Markdown
1518
- **CI/CD ready**: Exit codes and JSON output for automation
1619

@@ -89,6 +92,66 @@ cclint --format json --output report.json
8992
cclint --format markdown --output report.md
9093
```
9194

95+
### Git Integration (Diff-aware Linting)
96+
97+
Lint only changed files for fast pre-commit hooks:
98+
99+
```bash
100+
# Lint only staged files (perfect for pre-commit)
101+
cclint --staged
102+
103+
# Lint all uncommitted changes (staged + unstaged)
104+
cclint --diff
105+
```
106+
107+
If not in a git repository, falls back to full lint with a warning.
108+
109+
### Baseline Support (Gradual Adoption)
110+
111+
For legacy projects with existing issues, use baseline mode to adopt cclint incrementally:
112+
113+
```bash
114+
# Create baseline from current issues (accepts current state)
115+
cclint --baseline-create
116+
117+
# Lint with baseline - only NEW issues fail the build
118+
cclint --baseline
119+
120+
# Use custom baseline file
121+
cclint --baseline --baseline-path .baseline-legacy.json
122+
```
123+
124+
**Workflow:**
125+
1. Run `cclint --baseline-create` to snapshot current issues into `.cclintbaseline.json`
126+
2. Commit the baseline file to version control
127+
3. Run `cclint --baseline` in CI/CD — only new issues fail
128+
4. Fix issues incrementally, update baseline as needed
129+
130+
### Canonical Formatting
131+
132+
Format components with consistent style using `cclint fmt`:
133+
134+
```bash
135+
# Preview formatting (stdout)
136+
cclint fmt agents/my-agent.md
137+
138+
# Format in place
139+
cclint fmt --write agents/my-agent.md
140+
cclint fmt -w agents/
141+
142+
# Show diff of changes
143+
cclint fmt --diff agents/
144+
145+
# CI mode: exit 1 if formatting needed
146+
cclint fmt --check
147+
```
148+
149+
**Formatting rules:**
150+
- Frontmatter field order: `name`, `description`, `model`, `tools`/`allowed-tools`, then alphabetically
151+
- Exactly one blank line after frontmatter
152+
- Trailing whitespace removed
153+
- File ends with single newline
154+
92155
### Exit Codes
93156

94157
| Code | Meaning |
@@ -105,9 +168,12 @@ cclint validates references between components:
105168
| Check | Description |
106169
|-------|-------------|
107170
| **Skill existence** | Agents referencing non-existent skills produce errors |
171+
| **Circular dependencies** | Detects cycles in agent → skill → agent delegation chains |
108172
| **Orphan detection** | Skills not referenced by any agent/command show as suggestions |
109173
| **Tool permissions** | Commands using undeclared tools produce warnings |
110174

175+
To disable circular dependency detection: `cclint --no-cycle-check`
176+
111177
Skill references are detected in multiple formats:
112178
- `Skill: name` - Plain format (including inside code blocks)
113179
- `**Skill**: name` - Bold format
@@ -311,13 +377,16 @@ jobs:
311377
steps:
312378
- uses: actions/checkout@v4
313379

380+
- name: Set up Go
381+
uses: actions/setup-go@v5
382+
with:
383+
go-version: '1.23'
384+
314385
- name: Install cclint
315-
run: |
316-
go install github.com/dotcommander/cclint@latest
386+
run: go install github.com/dotcommander/cclint@latest
317387

318388
- name: Run cclint
319-
run: |
320-
cclint --format json --output cclint-report.json
389+
run: cclint --format json --output cclint-report.json
321390

322391
- name: Upload results
323392
if: always()
@@ -327,6 +396,13 @@ jobs:
327396
path: cclint-report.json
328397
```
329398
399+
**With baseline support (gradual adoption):**
400+
401+
```yaml
402+
- name: Run cclint with baseline
403+
run: cclint --baseline --format json --output cclint-report.json
404+
```
405+
330406
### GitLab CI
331407
332408
```yaml
@@ -349,17 +425,19 @@ Create `.git/hooks/pre-commit`:
349425

350426
```bash
351427
#!/bin/bash
352-
# Run cclint on commit
353-
cclint || exit 1
428+
# Run cclint on staged files only (fast!)
429+
cclint --staged || exit 1
354430
```
355431

356432
Or with [husky](https://github.com/typicode/husky):
357433

358434
```bash
359435
npm install --save-dev husky
360-
npx husky set .husky/pre-commit "cclint"
436+
npx husky set .husky/pre-commit "cclint --staged"
361437
```
362438

439+
Using `--staged` makes pre-commit hooks fast by only linting changed files.
440+
363441
## File Discovery
364442

365443
cclint searches the following locations:

docs/cross-file-validation.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ How cclint detects and validates references between components.
99
cclint performs cross-file validation to ensure components reference each other correctly. This includes:
1010

1111
1. **Skill Reference Validation** - Agents referencing skills that don't exist
12-
2. **Orphan Detection** - Skills not referenced by any agent/command
13-
3. **Tool Validation** - Commands using tools they haven't declared
12+
2. **Circular Dependency Detection** - Cycles in agent → skill → agent delegation chains
13+
3. **Orphan Detection** - Skills not referenced by any agent/command
14+
4. **Tool Validation** - Commands using tools they haven't declared
1415

1516
## Skill Reference Detection
1617

@@ -58,6 +59,50 @@ Key components:
5859

5960
**Important:** The `\n` exclusion is critical. Without it, Go's regex engine would greedily match across newlines, causing only the last skill in a block to be detected.
6061

62+
## Circular Dependency Detection
63+
64+
### What It Checks
65+
66+
Circular dependencies occur when components form a loop in their reference chain:
67+
68+
```
69+
agent-a → skill-b → agent-c → skill-d → agent-a (cycle!)
70+
```
71+
72+
These cycles can cause infinite loops in Claude Code when agents delegate to each other.
73+
74+
### How It Works
75+
76+
cclint uses DFS (Depth-First Search) with color marking to detect back edges in the component graph:
77+
78+
1. **White (unvisited)** - Node not yet processed
79+
2. **Gray (in progress)** - Node is in current DFS path
80+
3. **Black (complete)** - Node fully processed
81+
82+
A cycle is detected when we encounter a gray node while exploring.
83+
84+
### Output
85+
86+
Cycles are reported as errors on all involved agents:
87+
88+
```bash
89+
$ cclint agents
90+
91+
✗ agents/agent-a.md
92+
✘ Circular dependency detected: agent:agent-a → skill:shared-skill → agent:agent-a
93+
94+
✗ agents/agent-c.md
95+
✘ Circular dependency detected: agent:agent-a → skill:shared-skill → agent:agent-a
96+
```
97+
98+
### Disabling
99+
100+
To disable circular dependency detection (not recommended):
101+
102+
```bash
103+
cclint --no-cycle-check agents
104+
```
105+
61106
## Orphan Detection
62107

63108
### What It Checks

0 commit comments

Comments
 (0)