agentleFS
anthrilanthril/vibe-guard/.claude/CLAUDE.md

vibe-guard

CLAUDE.md2 starsChanged 8 months agoApache-2.0View on GitHub

VGuard (VibeGuard) is a runtime-enforced AI coding guardrails framework. It generates hook scripts for AI agents (Claude Code, Cursor, Codex, OpenCode) that enforce security, quality, and workflow rules during AI coding sessions. Use these project commands for common development tasks: Use these skills for scaffolding and release:

The file

We split this CLAUDE.md into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use these project commands for common development tasks:

    line 62
  2. Distinctive:

    Use these skills for scaffolding and release:

    line 74
  3. Very specific:

    Use the /new-rule skill or follow manually:

    line 85
  4. Very specific:

    Create src/rules/{category}/{rule-name}.ts exporting a Rule object

    line 87
  5. Very specific:

    Add to relevant presets in src/presets/

    line 90

≈ “Common” is an estimate: at least 1 in 5 of the 27,641 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

VGuard — Project Instructions

What is VGuard?

VGuard (VibeGuard) is a runtime-enforced AI coding guardrails framework. It generates hook scripts for AI agents (Claude Code, Cursor, Codex, OpenCode) that enforce security, quality, and workflow rules during AI coding sessions.

Architecture

Layer 5: ANALYTICS (reports, drift detection)
Layer 4: LEARNING (convention extraction from codebases)
Layer 3: WORKFLOW (git flow, PR templates, commit conventions)
Layer 2: QUALITY (imports, naming, anti-patterns, file structure)
Layer 1: SECURITY (branch protection, secrets, destructive commands)
Layer 0: CORE ENGINE (hook runner, config parser, rule resolver)

Key Directories

  • src/engine/ — Core hook execution: runner, resolver, context, scanner, tracker, edit-rule-factory
  • src/rules/{security,quality,workflow}/ — Built-in rules. Each rule exports a Rule object
  • src/config/ — Config loading, Zod validation, preset merging, pre-compilation
  • src/adapters/ — Output generators per agent (claude-code, cursor, codex, opencode, github-actions)
  • src/learn/ — Convention learning engine (analyzers, promoter, walker)
  • src/cli/commands/ — CLI commands (init, add, remove, generate, doctor, lint, learn, report, eject, upgrade)
  • src/presets/ — Ecosystem presets (nextjs-15, typescript-strict, react-19, tailwind, supabase, django, fastapi, laravel)
  • src/plugins/ — Plugin loader and validator
  • tests/ — Vitest tests mirroring src/ structure

Development Commands

npm run build        # Build with tsup (dual ESM/CJS)
npm run dev          # Watch mode build
npm test             # Run tests
npm run test:coverage # Run tests with coverage
npm run lint         # ESLint
npm run type-check   # TypeScript strict type checking
npm run format       # Prettier

Conventions

  • TypeScript strict mode — no any, no unused vars (leading _ allowed)
  • Dual ESM/CJS output — import paths use .js extension (e.g., from './types.js')
  • Rule pattern: export a Rule object with id, name, description, severity, events, match, check()
  • Fail-open philosophy — every try/catch exits 0. Internal errors never block developer work
  • Edit rule factory — createEditVariant() auto-generates Edit variants that only flag newly introduced issues
  • Conventional commits enforced by commitlint: feat(scope): message
  • Test files mirror source structure: src/rules/security/foo.ts → tests/rules/security/foo.test.ts
  • Prettier: semicolons, single quotes, trailing commas, 100 char width

Critical Design Decisions

  1. Hook scripts are pre-compiled to .vguard/cache/resolved-config.json for fast execution (<100ms target)
  2. Tracker (.vguard/data/rule-hits.jsonl) is append-only JSONL with 10MB auto-rotation — this is the data layer Cloud will consume
  3. Config resolution: defaults → presets → user rules. Severity can only be downgraded, never upgraded by presets
  4. Claude Code adapter generates hooks and merges into .claude/settings.json — it does NOT overwrite existing settings

Slash Commands

Use these project commands for common development tasks:

CommandPurpose
/project:add-ruleScaffold a new rule with file, test, and registration
/project:add-presetScaffold a new preset for a tech stack
/project:run-testsRun test suite and analyze failures
/project:buildBuild, type-check, lint, and verify dist output
/project:adapter-checkVerify all adapter outputs are correct

Skills

Use these skills for scaffolding and release:

SkillTriggerWhat It Does
/new-rule"create a rule", "add rule"Rule file + test + registration
/new-preset"create a preset", "add preset"Preset file + registration
/new-adapter"add adapter", "support new agent"Adapter file + type updates
/release"release", "publish", "bump version"Full release: version bump, changelog, checks, PR, CI monitoring, changelog discussion

Adding a New Rule

Use the /new-rule skill or follow manually:

  1. Create src/rules/{category}/{rule-name}.ts exporting a Rule object
  2. Register in src/rules/{category}/index.ts
  3. Create tests/rules/{category}/{rule-name}.test.ts
  4. Add to relevant presets in src/presets/

Adapter System

Each adapter in src/adapters/ generates agent-specific files:

AdapterGenerated FilesStrategy
claude-code.vguard/hooks/*.js, .claude/settings.json, .claude/commands/vguard-*.md, .claude/rules/vguard-enforcement.mdhooks: overwrite, settings: merge, commands: create-only, rules: overwrite
cursor.cursorrules, .cursor/rules/*.mdcoverwrite
codexAGENTS.md, .codex/instructions.mdoverwrite / create-only
opencode.opencode/instructions.mdoverwrite
github-actions.github/workflows/vguard.ymlcreate-only

Git Workflow

  • master — production, squash merges from dev via PR only
  • dev — integration branch, all work merges here first
  • Branch from dev: feature/<name>, fix/<name>, chore/<name>

Enforcement Rules

Pre-Commit Hooks (.husky/pre-commit)

  1. Lint + Type-check — always runs on every commit
  2. CHANGELOG.md required — on dev, master, main branches, CHANGELOG.md must be staged
  3. Version bump required — on master/main branches, package.json must be staged (version bump)

CI Checks (.github/workflows/ci.yml)

  • release-checks job — runs only on PRs targeting master:
    • Fails if package.json version matches the current master version (no bump)
    • Fails if CHANGELOG.md has no diff compared to master

Publish Workflow (.github/workflows/publish.yml)

  • Triggers on push to master (PR merge)
  • preflight — checks if PR merge, version unpublished, tag missing
  • validate — full CI (lint, format, type-check, test, build)
  • publish — npm publish with OIDC provenance, git tag, GitHub Release

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.