Hamburger Cross Icon
Instruction File Sections
+
AI Collector

Instruction File Sections + AI Collector

Guardrail Collector Experimental Devex Build And Ci

Enforce Instruction File Sections using data collected by AI Collector. Automatically check devex build and ci standards on every PR.

Guardrail: Ensures the root instruction file contains required section headings. Validates that essential information like project overview and build commands is documented for AI agents.
Data Source: Track tool-agnostic AI coding assistant usage across your organization. Collects agent instruction files, plans directories, and AI authorship annotations. Part of the unified ai.* namespace.

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.

1
AI Collector Gathers Data Collector
Extracts metadata from code, configs, and tool outputs
2
{ } Component JSON
Data centralized in structured format for evaluation
3
Instruction File Sections Checks Guardrail
Pass/fail result with actionable feedback in PRs

Quick Start Configuration

Add both the collector and policy to your lunar-config.yml to enable this guardrail.

📄 lunar-config.yml
# 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.

Collector code

instruction-files

Discovers the vendor-neutral AGENTS.md instruction file across the repository. Records each file's path, line count, byte size, markdown section headings, and symlink status. Tool-specific instruction files (CLAUDE.md, CODEX.md, GEMINI.md) are discovered by their respective tool collectors.

Collector code

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.

Collector code

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.

{ } component.json From AI Collector
{
  "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.

Works with any process
check AI agent rules & prompt files
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo