Instruction File Sections + AI Collector
Enforce Instruction File Sections using data collected by AI Collector. Automatically check devex build and ci standards on every PR.
How AI Collector Powers This Guardrail
The AI Collector gathers metadata from your code analysis systems. This data flows into Lunar's Component JSON, where the Instruction File Sections guardrail evaluates it against your standards.
When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# Step 1: Enable the AI Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/ai@v1.0.5
# with: ...
# Step 2: Enable the AI Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/ai@v1.0.5
include: [instruction-file-sections]
# with: ...
What AI Collector Collects
This collector gathers the following data that the Instruction File Sections guardrail evaluates.
instruction-files
plans-dir
Checks whether a dedicated plans directory exists for AI agent task planning. Tries candidate paths in order (first match wins). Records the directory path and file count.
ai-authorship
Collects AI authorship annotation data from commits. Supports the Git AI standard (refs/notes/ai) for line-level tracking and git trailers (AI-model, AI-tokens) as a lightweight fallback. Records annotation coverage across commits in scope.
Example Data Flow
Here's an example of the data that AI Collector writes to the Component JSON, which Instruction File Sections then evaluates.
{
"ai": {
"instructions": {
"root": {
"exists": true,
"filename": "AGENTS.md",
"lines": 85,
"bytes": 3200,
"sections": ["Project Overview", "Architecture", "Build Commands", "Testing"]
},
"all": [
{
"path": "AGENTS.md",
"dir": ".",
"filename": "AGENTS.md",
"lines": 85,
"bytes": 3200,
"sections": ["Project Overview", "Architecture", "Build Commands", "Testing"],
"is_symlink": false,
"symlink_target": null
}
],
"count": 1,
"total_bytes": 3200,
"source": { "tool": "find", "integration": "code" }
},
"plans_dir": {
"exists": true,
"path": ".agents/plans",
"file_count": 3
},
"authorship": {
"provider": "git-ai",
"total_commits": 12,
"annotated_commits": 8,
"git_ai": {
"notes_ref_exists": true,
"commits_with_notes": 8
}
}
}
}
Configuration Options
AI Collector Inputs
| Input | Required | Default | Description |
|---|---|---|---|
md_find_command |
Optional |
find . \( -type f -o -type l \) -name AGENTS.md -not -path '*/node_modules/*' -not -path '*/.git/*'
|
Command to find AGENTS.md instruction files (must output one file path per line) |
plans_dir_paths |
Optional |
.agents/plans,.ai/plans
|
Comma-separated list of candidate paths for the plans directory (first match wins) |
annotation_prefix |
Optional |
AI-
|
Prefix for git trailer-based AI annotations |
default_branch_window |
Optional |
50
|
Number of recent commits to scan on the default branch |
AI Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
canonical_filename |
Optional |
AGENTS.md
|
The canonical (vendor-neutral) instruction filename |
min_lines |
Optional |
10
|
Minimum number of lines for the root instruction file (0 to disable) |
max_lines |
Optional |
300
|
Maximum number of lines for the root instruction file (0 to disable) |
max_total_bytes |
Optional |
32768
|
Maximum combined bytes across all instruction files (0 to disable) |
required_sections |
Optional |
Project Overview,Build Commands
|
Comma-separated required section heading substrings (case-insensitive) |
min_annotation_percentage |
Optional |
0
|
Minimum percentage of commits that should have AI annotations (0 = awareness mode) |
Ready to Automate Your Standards?
See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 200+ built-in guardrails.