Skip to content

Commit 9305118

Browse files
Juan C. Guerreroclaude
authored andcommitted
feat: scaffold DojoWatch as Claude Code plugin + CI scripts (Phase 1)
AI-native visual regression testing engine — captures screenshots with Playwright, pre-filters with pixelmatch, and uses Claude (locally) or Gemini (in CI) as the diff engine. Plugin components: - 5 slash commands: /vr-init, /vr-check, /vr-approve, /vr-report, /vr-watch - regression-analyzer agent for root-cause tracing - visual-regression skill with classification schema + analysis prompt Core scripts: - capture.ts: Playwright capture engine with stabilization and masking - baseline.ts: SHA-256 hashing, baseline promotion - config.ts: .dojowatch/config.json loader with defaults - route-map.ts: source file → route mapping with git-aware scope resolution - types.ts: shared TypeScript types Also includes CI workflow, issue templates, config example, and GitHub Actions template for consumer projects. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e53821d commit 9305118

40 files changed

+5067
-0
lines changed

.claude-plugin/plugin.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "dojowatch",
3+
"version": "0.1.0",
4+
"description": "AI-native visual regression testing — capture, diff, and analyze UI changes with LLM vision",
5+
"author": {
6+
"name": "Dojo Coding LLC",
7+
"url": "https://github.com/DojoCodingLabs"
8+
},
9+
"repository": "https://github.com/DojoCodingLabs/dojowatch",
10+
"license": "MIT",
11+
"keywords": [
12+
"visual-regression",
13+
"testing",
14+
"playwright",
15+
"ai",
16+
"screenshot",
17+
"diff"
18+
]
19+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug in DojoWatch
4+
title: "[Bug] "
5+
labels: bug
6+
---
7+
8+
## Description
9+
10+
A clear description of the bug.
11+
12+
## Steps to reproduce
13+
14+
1.
15+
2.
16+
3.
17+
18+
## Expected behavior
19+
20+
What should happen.
21+
22+
## Actual behavior
23+
24+
What actually happens.
25+
26+
## Environment
27+
28+
- DojoWatch version:
29+
- Node.js version:
30+
- OS:
31+
- Framework (Next.js, Vite, etc.):
32+
- Using Claude Code plugin: yes/no
33+
- Using CI (GitHub Actions): yes/no
34+
35+
## Screenshots
36+
37+
If applicable, add screenshots.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature for DojoWatch
4+
title: "[Feature] "
5+
labels: enhancement
6+
---
7+
8+
## Problem
9+
10+
What problem does this feature solve?
11+
12+
## Proposed solution
13+
14+
How should it work?
15+
16+
## Alternatives considered
17+
18+
Any alternative approaches you've thought about.
19+
20+
## Additional context
21+
22+
Any other context, screenshots, or references.

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 24
18+
cache: npm
19+
20+
- run: npm ci
21+
22+
- name: Type check
23+
run: npm run typecheck
24+
25+
- name: Test
26+
run: npm run test:run

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
7+
# DojoWatch runtime artifacts (captures and diffs are ephemeral)
8+
.dojowatch/captures/
9+
.dojowatch/diffs/
10+
11+
# Environment
12+
.env
13+
.env.local
14+
.env*.local
15+
16+
# IDE
17+
.vscode/
18+
.idea/
19+
*.swp
20+
*.swo
21+
*~
22+
23+
# OS
24+
.DS_Store
25+
Thumbs.db
26+
27+
# TypeScript
28+
*.tsbuildinfo
29+
30+
# Test coverage
31+
coverage/

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
## [0.1.0] — Unreleased
4+
5+
### Added
6+
- Initial project structure as Claude Code plugin + standalone scripts
7+
- **Capture engine** (`scripts/capture.ts`): Playwright-based screenshot capture with configurable routes and viewports
8+
- **Stabilization** (`scripts/stabilize.ts`): Animation freeze, network idle wait, font loading, element masking
9+
- **Baseline management** (`scripts/baseline.ts`): SHA-256 hashing, promote captures to baselines
10+
- **Config loader** (`scripts/config.ts`): `.dojowatch/config.json` with sensible defaults
11+
- **Route map** (`scripts/route-map.ts`): Source file → route mapping with git-aware scope resolution
12+
- **Slash commands**: `/vr-init`, `/vr-check`, `/vr-approve`, `/vr-report`, `/vr-watch` (stub)
13+
- **Agent**: `regression-analyzer` for deep-diving into regression root causes
14+
- **Skill**: `visual-regression` with classification schema and analysis prompt references
15+
- **Templates**: Example config, GitHub Actions workflow
16+
- **CI**: GitHub Actions workflow for linting, testing, type checking

CLAUDE.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# DojoWatch
2+
3+
AI-native visual regression testing engine — Claude Code plugin + GitHub Actions CI.
4+
5+
## Architecture
6+
7+
- **Plugin-first**: Slash commands are the primary local interface. Claude Code IS the local AI engine.
8+
- **Scripts in `scripts/`**: Standalone TypeScript, runnable via `npx tsx`. Used by both slash commands and CI.
9+
- **Gemini for CI**: `scripts/analyze-gemini.ts` handles batch analysis in GitHub Actions.
10+
- **No npm publish**: This is a Claude Code plugin, not a published package.
11+
12+
## Conventions
13+
14+
- TypeScript strict mode, ESM only (`"type": "module"`)
15+
- All shared types in `scripts/types.ts`
16+
- Pre-filter has a **zero false-negative guarantee**: only byte-identical screenshots skip analysis
17+
- Scripts must be runnable standalone (for CI) AND callable from slash commands via Bash
18+
- Use `picocolors` for terminal output, never `chalk`
19+
- Use `execFileSync` not `execSync` — avoid shell injection
20+
- Test fixtures in `tests/fixtures/`
21+
22+
## File layout
23+
24+
| Directory | Purpose |
25+
|-----------|---------|
26+
| `commands/` | Claude Code slash commands (markdown with YAML frontmatter) |
27+
| `agents/` | Claude Code agents (markdown with YAML frontmatter) |
28+
| `skills/` | Claude Code skills (`SKILL.md` + `references/`) |
29+
| `scripts/` | Core TypeScript scripts (capture, prefilter, analyze, etc.) |
30+
| `templates/` | User-facing templates (config example, GitHub Actions) |
31+
| `tests/` | Vitest tests + PNG fixtures |
32+
33+
## Script naming
34+
35+
Scripts double as both importable modules and CLI entrypoints:
36+
- Export functions for programmatic use
37+
- Include `if (isDirectRun)` block for CLI execution
38+
- Accept args via `process.argv` when run directly
39+
40+
## Classification schema
41+
42+
Visual diffs are classified as:
43+
- **REGRESSION**: Unintended visual change (bug). Severity: high/medium/low.
44+
- **INTENTIONAL**: Deliberate change (feature, design update).
45+
- **NOISE**: Insignificant rendering variance (anti-aliasing, sub-pixel).
46+
47+
See `skills/visual-regression/references/classification-schema.md` for full criteria.

CONTRIBUTING.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Contributing to DojoWatch
2+
3+
Thanks for your interest in contributing to DojoWatch!
4+
5+
## Development setup
6+
7+
1. Clone the repo:
8+
```bash
9+
git clone https://github.com/DojoCodingLabs/dojowatch.git
10+
cd dojowatch
11+
```
12+
13+
2. Install dependencies:
14+
```bash
15+
npm install
16+
```
17+
18+
3. Install Playwright browsers:
19+
```bash
20+
npx playwright install chromium
21+
```
22+
23+
4. Run tests:
24+
```bash
25+
npm test
26+
```
27+
28+
5. Test the plugin locally:
29+
```bash
30+
claude --plugin-dir ./
31+
```
32+
33+
## Project structure
34+
35+
- `commands/` — Slash commands for Claude Code (markdown)
36+
- `agents/` — Claude Code agents (markdown)
37+
- `skills/` — Auto-activating skills with references
38+
- `scripts/` — Core TypeScript modules (capture, prefilter, baseline, etc.)
39+
- `tests/` — Vitest tests with PNG fixtures
40+
- `templates/` — User-facing config and CI templates
41+
42+
## Writing scripts
43+
44+
Scripts serve dual purposes — importable modules AND standalone CLI tools:
45+
46+
```typescript
47+
// Export functions for programmatic use
48+
export function myFunction() { ... }
49+
50+
// CLI entrypoint when run directly
51+
const isDirectRun = process.argv[1]?.endsWith("my-script.ts");
52+
if (isDirectRun) {
53+
main();
54+
}
55+
```
56+
57+
## Writing slash commands
58+
59+
Commands are markdown files in `commands/` with YAML frontmatter:
60+
61+
```markdown
62+
---
63+
description: Short description shown in /help
64+
argument-hint: "[optional args]"
65+
---
66+
67+
# Command Name
68+
69+
Instructions for Claude on how to execute this command...
70+
```
71+
72+
Commands instruct Claude what to do — they run scripts via Bash and use Claude's multimodal capabilities for analysis.
73+
74+
## Testing
75+
76+
```bash
77+
npm test # Watch mode
78+
npm run test:run # Single run
79+
npm run typecheck # Type checking
80+
npm run lint # Linting
81+
```
82+
83+
Test fixtures (PNG pairs) live in `tests/fixtures/`. When adding new test cases, include PNG pairs that demonstrate the specific scenario.
84+
85+
## Pull requests
86+
87+
1. Create a branch from `main`
88+
2. Make your changes
89+
3. Ensure `npm run typecheck && npm run test:run` passes
90+
4. Submit a PR with a clear description of what changed and why
91+
92+
## Code of conduct
93+
94+
Be kind, be constructive, be collaborative.

0 commit comments

Comments
 (0)