Define what matters to your team as markdown files with YAML frontmatter.
Rules live in .saguaro/rules/ as markdown files with YAML frontmatter. Each rule defines a single convention or constraint that Saguaro enforces during review.
| Field | Required | Description |
|---|---|---|
id | Yes | Unique identifier, kebab-case |
title | Yes | Human-readable name |
severity | Yes | error (blocks, exit 1), warning (logged), or info |
globs | No | File patterns to match. Default: all files. Prefix ! to exclude. |
1---2id: no-console-log3title: No console.log in production code4severity: warning5globs:6 - "**/*.ts"7 - "**/*.tsx"8 - "!**/*.test.ts"9---10
11console.log, console.warn, and console.debug should not appear in12production code. Use a structured logging library instead.13
14### Violations15
16\`\`\`17console.log("Processing order", orderId, customerEmail);18\`\`\`19
20### Compliant21
22\`\`\`23logger.info("Processing order", { orderId });24\`\`\`2.1Generate from codebase — sag rules generate analyzes your code and proposes rules based on patterns and conventions it detects in your project.
1# Analyze your codebase and propose rules2sag rules generate2.2Create with AI assistance — sag rules create [target] creates a rule scoped to a specific directory or file pattern, using AI to draft the rule content.
1# Create a rule scoped to a specific directory2sag rules create src/api2.3Write by hand — create a .md file in .saguaro/rules/ following the format above. This gives you full control over the rule content and structure.
3.1Specific — targets a concrete behavior, not a vague guideline. A good rule describes exactly what to do and what not to do.
3.2Scoped — uses globs to target only relevant files. A rule about API error handling should match src/api/**/*.ts, not everything.
3.3Has examples — includes ### Violations and ### Compliant sections with code snippets so the AI reviewer knows exactly what to look for.
3.4Right severity — error for things that must block, warning for preferences, info for suggestions.
1---2id: use-custom-errors3title: Use AppError instead of generic Error4severity: error5globs:6 - "src/**/*.ts"7 - "!src/**/*.test.ts"8---9
10Always throw AppError with a specific error code instead of generic11Error. This ensures consistent error handling and makes errors12programmatically distinguishable.13
14### Violations15
16\`\`\`typescript17throw new Error("User not found");18throw new Error(\`Invalid input: \${value}\`);19\`\`\`20
21### Compliant22
23\`\`\`typescript24throw new AppError("USER_NOT_FOUND", "User not found");25throw new AppError("INVALID_INPUT", \`Invalid input: \${value}\`);26\`\`\`*.test.ts filesSaguaro provides CLI commands for managing your rules directory.
| Command | Description |
|---|---|
sag rules list | List all rules |
sag rules explain <id> | Show full details for a rule |
sag rules validate | Check rule structure and frontmatter |
sag rules delete <id> | Delete a rule by its ID |
sag rules locate | Print the rules directory path |
sag rules validate in CI to catch malformed rules before they reach productionsrc/api/**/*.ts rather than broad wildcards.