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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .claude/rules/core-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ globs:
- "agents/*/rules/**"
---

# Backbone Index Sync
# Coordinate Map Sync

After creating, deleting, or renaming a rule directory, update `rules.index` in `.reporails/backbone.yml` to keep the index complete.
After creating, deleting, or renaming a rule directory, update `registry/coordinate-map.yml` to keep the mapping complete.

Format: `{ID}: {slug}` (e.g., `M4: backbone-index-completeness`).
Format: `slug: "COORDINATE"` (e.g., `backbone-index-completeness: "CORE:M:0004"`).

See rule M4 for the completeness requirement.
See rule CORE:M:0004 for the completeness requirement.
4 changes: 2 additions & 2 deletions .claude/rules/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ globs:
- ".claude/skills/**"
---

# Backbone Artifact References
# Backbone Path References

Skills resolve paths from `.reporails/backbone.yml`. When referencing a new artifact (schema, source file, etc.), verify the path exists in `backbone.artifacts` or `backbone.schemas`.
Skills resolve paths from `.reporails/backbone.yml`. When referencing a new schema or registry file, verify the path exists in `backbone.schemas` or `backbone.registry`.

See `.shared/knowledge/backbone-resolution.md` for the full resolution table.
24 changes: 14 additions & 10 deletions .claude/skills/add-changelog-entry/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ Automatically add a changelog entry to PROJECT_ROOT/UNRELEASED.md.

1. Check git diff or recent file modifications
2. Determine the area from the file path:
- rules/*.md → [RULES]
- capability-levels.md with L1-L6 changes → [L1]-[L6]
- README.md → [DOCS]
- core/**/rule.md → [RULES]
- registry/ → [REGISTRY]
- schemas/ → [SCHEMAS]
- agents/ → [AGENTS]
- docs/ → [DOCS]
- CLAUDE.md, backbone.yml, .claude/, .reporails/ → [META]
3. Determine the category:
- New files/content → Added
Expand All @@ -39,20 +41,22 @@ Added, Changed, Deprecated, Removed, Fixed, Security

## Areas

- [RULES] – Rule definitions (S, C, M, G, E)
- [L1]-[L6] – Level-specific changes
- [DOCS] – README, general documentation
- [RULES] – Rule definitions (structure, content, efficiency, maintenance, governance)
- [REGISTRY] – Capabilities, levels, coordinate map, tombstones
- [SCHEMAS] – Schema definitions
- [AGENTS] – Agent configurations and agent-specific rules
- [DOCS] – Documentation
- [META] – CLAUDE.md, backbone.yml, repo structure

## Example

```markdown
### Added
- [RULES]: S5 rule for heading depth validation
- [L4]: Added hooks requirement to level definition
- [RULES]: CORE:G:0001 rule for governance policy validation
- [REGISTRY]: Added new capability to L4

### Changed
- [DOCS]: Updated README with CLI link
- [SCHEMAS]: Updated rule schema to v0.1.0
```

Do not ask for confirmation. Just do it.
Do not ask for confirmation. Just do it.
38 changes: 22 additions & 16 deletions .claude/skills/generate-rule/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,50 @@ description: Generate a rule skeleton with proper schema and directory structure

# /generate-rule

Generate a rule skeleton with proper directory structure, frontmatter, and placeholder files.
Generate a rule skeleton with coordinate-based ID, directory structure, and placeholder files.

## Usage

```
/generate-rule <id> <scope> <title> [--agent <name>]
/generate-rule <coordinate> <scope> <title> [--agent <name>]
```

- `<id>`: Rule ID (e.g., S5, C6, CLAUDE_S3)
- `<coordinate>`: Rule coordinate (e.g., CORE:S:0005, CLAUDE:S:0003)
- `<scope>`: `core` or agent name (e.g., `claude`)
- `<title>`: Short title for the rule
- `--agent <name>`: Agent for path resolution (default: `claude`)

## Examples

```
/generate-rule S5 core "My New Rule"
/generate-rule CLAUDE_S3 claude "Some Agent Rule"
/generate-rule CORE:S:0005 core "My New Rule"
/generate-rule CLAUDE:S:0003 claude "Some Agent Rule"
```

## Workflow

Follow: [workflow.md](workflow.md)
1. Validate coordinate is not in `registry/tombstones.yml`
2. Validate coordinate slot is not already taken in `registry/coordinate-map.yml`
3. Determine category from coordinate letter (S/C/E/M/G)
4. Resolve directory path from `backbone.rules.patterns` and `backbone.rules.categories`
5. Create directory: `{category_path}/{slug}/`
6. Generate `rule.md` with frontmatter (id, slug, title, category, type, level, targets, checks)
7. Generate `rule.yml` with OpenGrep patterns (if deterministic/semantic)
8. Create `tests/pass/` and `tests/fail/` directories with `.gitkeep`
9. Update `registry/coordinate-map.yml` with new slug→coordinate entry

## Reference

- [Rule authoring](rule-authoring.md) — Templates and validation

## Path Resolution

Resolve all rule and artifact paths from `.reporails/backbone.yml` instead of hardcoding.
See [@.shared/knowledge/backbone-resolution.md](../../../.shared/knowledge/backbone-resolution.md) for the resolution table and ID-to-path algorithm.
- Schema: `schemas/rule.schema.yml` — field definitions and validation rules
- Registry: `registry/coordinate-map.yml` — existing coordinates
- Registry: `registry/tombstones.yml` — dead slots

## Quick Reference

| Decision | Result |
|----------|--------|
| OpenGrep fully decides | type: deterministic |
| LLM needed | type: semantic (add question + criteria) |
| Has backing sources | Add to backed_by (optional) |
| No backing sources | `backed_by: []` (valid default) |
| Structural/file checks only | type: mechanical |
| OpenGrep pattern matching | type: deterministic |
| LLM evaluation needed | type: semantic (prompt field on terminal check) |
| Has backing sources | Add to backed_by with source IDs from docs/sources.yml |
| No backing sources | Omit backed_by (optional field) |
14 changes: 9 additions & 5 deletions .claude/skills/generate-rule/rule-authoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ title: {Title} # max 64 chars
category: structure|content|efficiency|maintenance
type: deterministic|semantic
checks:
- id: {ID}-{check-slug}
- id: "{RULE_ID}:check:{SLOT}"
name: {Description}
severity: critical|high|medium|low
backed_by: [] # empty by default
Expand Down Expand Up @@ -49,7 +49,7 @@ criteria:

```yaml
rules:
- id: {ID}-{check-slug}
- id: "{RULE_ID}.check.{SLOT}"
message: "TODO: {description}"
severity: WARNING
languages: [generic]
Expand All @@ -63,8 +63,12 @@ rules:

| Scope | Pattern | Example |
|-------|---------|---------|
| Core | `^[SCEGM][0-9]+$` | S1, C5, E2 |
| Agent | `^[A-Z]+_[SCEGM][0-9]+$` | CLAUDE_S1 |
| Core | `CORE:{CAT}:{SLOT}` | `CORE:S:0001`, `CORE:C:0010` |
| Agent | `{AGENT}:{CAT}:{SLOT}` | `CLAUDE:S:0001`, `CODEX:S:0003` |
| Recommended | `RRAILS:{CAT}:{SLOT}` | `RRAILS:C:0008`, `RRAILS:E:0002` |
| Recommended Agent | `RRAILS_{AGENT}:{CAT}:{SLOT}` | `RRAILS_CLAUDE:S:0001` |

**Check IDs**: `{RULE_ID}:check:{SLOT}` in rule.md (colons), `{RULE_ID}.check.{SLOT}` in rule.yml (dots — colons invalid in OpenGrep).

## Valid Values

Expand All @@ -90,7 +94,7 @@ rules:
|---------|-----|
| Using `{{rules_dir}}` in core rules | Core uses only `{{instruction_files}}` |
| Missing .yml file | Always create both files |
| Wrong check ID format | Must be `{rule_id}-{suffix}` |
| Wrong check ID format | Must be `{RULE_ID}:check:{SLOT}` (colons in .md, dots in .yml) |
| Semantic without question | Add question + criteria |
| Deterministic with question | Remove question + criteria |
| Hardcoded paths in .yml | Use `{{instruction_files}}` |
Expand Down
44 changes: 24 additions & 20 deletions .claude/skills/generate-rule/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,51 @@

```mermaid
flowchart TD
START([/generate-rule id scope title]) --> GATHER[Gather: what, why, type]
GATHER --> TYPE{OpenGrep fully decides?}
TYPE -->|Yes| DET[type: deterministic]
TYPE -->|No| SEM[type: semantic<br/>Add question + criteria]
DET --> GEN[Generate skeleton files]
START([/generate-rule coordinate scope title]) --> GATHER[Gather: what, why, type]
GATHER --> TYPE{Detection method?}
TYPE -->|Structural checks only| MECH[type: mechanical]
TYPE -->|OpenGrep fully decides| DET[type: deterministic]
TYPE -->|Needs LLM judgment| SEM[type: semantic<br/>Add question + criteria]
MECH --> GEN[Generate skeleton files]
DET --> GEN
SEM --> GEN
GEN --> MD[Create .md with frontmatter<br/>+ Good/Bad examples]
MD --> YML[Create .yml with placeholder pattern]
YML --> TESTS[Create tests/pass.md + tests/fail.md]
TESTS --> INDEX[Update backbone rules.index]
INDEX --> CHANGELOG[/add-changelog-entry]
GEN --> MD[Create rule.md with frontmatter<br/>+ Pass/Fail examples]
MD --> YML[Create rule.yml<br/>patterns or empty rules list]
YML --> TESTS[Create tests/pass/ + tests/fail/]
TESTS --> COORDMAP[Update registry/coordinate-map.yml]
COORDMAP --> CHANGELOG[/add-changelog-entry]
```

## What Gets Generated

| File | Content |
|------|---------|
| `{id}-{slug}.md` | Frontmatter + heading + Pattern section (Good/Bad) |
| `{id}-{slug}.yml` | Placeholder with TODO pattern |
| `tests/pass.md` | Empty file with TODO comment |
| `tests/fail.md` | Empty file with TODO comment |
| `rule.md` | Frontmatter (id, slug, title, category, type, level, checks, backed_by) + prose |
| `rule.yml` | OpenGrep patterns (deterministic/semantic) or `rules: []` (mechanical) |
| `tests/pass/` | Empty — populated by `/implement-rule` |
| `tests/fail/` | Empty — populated by `/implement-rule` |

## Placeholder .yml
## Placeholder .yml (deterministic/semantic)

```yaml
rules:
- id: {ID}-{check-slug}
message: "TODO: {description}"
- id: NAMESPACE.CATEGORY.SLOT.check.0001
message: "{description}"
severity: WARNING
languages: [generic]
pattern-regex: "TODO" # placeholder — to be filled by tooling or contributor
pattern-regex: "TODO" # placeholder — to be filled by /implement-rule
paths:
include:
- "{{instruction_files}}"
```

Mechanical rules get `rules: []` — no OpenGrep patterns needed.

## Edge Cases

**Core vs Agent rules:**
- Core rules use only `{{instruction_files}}`
- Agent rules can use `{{rules_dir}}`, `{{skills_dir}}`, etc.

**Path resolution:** Resolve rule paths from `.reporails/backbone.yml` using `rules.index`, `rules.categories`, and `rules.patterns`.
See [@.shared/knowledge/backbone-resolution.md](../../../.shared/knowledge/backbone-resolution.md) for the ID-to-path algorithm and directory structure.
**Path resolution:** Resolve rule paths from `.reporails/backbone.yml` using `rules.categories` and `rules.patterns`.
See [@.shared/knowledge/backbone-resolution.md](../../../.shared/knowledge/backbone-resolution.md) for the coordinate-to-path algorithm.
Loading