Hamburger Cross Icon
Claude Collector - Lunar Collector

Claude Collector

Collector Experimental Code Analysis

Detects Claude Code Review on pull requests, captures Claude CLI invocations in CI, discovers CLAUDE.md instruction files, and runs custom Claude prompts against code. Writes to normalized ai.code_reviewers[] plus Claude-specific data in ai.native.claude.

Add claude to your lunar-config.yml:
uses: github://earthly/lunar-lib/collectors/claude@v1.0.5

What This Integration Collects

This integration includes 5 collectors that gather metadata from your systems.

Collector code

code-reviewer

Detects Claude Code Review check-runs on pull requests by querying the GitHub check-runs API. Waits for scan completion and writes a normalized entry to ai.code_reviewers[].

claude code review ai review pull request
Book a demo
Collector code

run-code-review

Runs the Claude CLI in review mode against pull request diffs. Captures review findings, severity levels, and affected files. Writes results to ai.native.claude.code_review for Claude-specific policy evaluation.

claude code review ai review pull request claude cli
Book a demo
Collector ci-after-command

cicd

Detects Claude Code CLI invocations in CI pipelines. Records the command string, version, and extracted flags (--allowedTools, --disallowedTools, --mcp-config) for policy-level analysis. Also appends to ai.code_reviewers[] when it detects review-mode invocations (e.g. claude --review).

claude claude code ai ci ci safety
Book a demo
Collector code

instruction-file

Discovers CLAUDE.md instruction files across the repository. Records file path, line count, byte size, and whether it is a symlink to AGENTS.md. Writes to ai.native.claude.instruction_file and appends to ai.instructions.all[] for normalized cross-tool access.

claude.md instruction file agent context
Book a demo
Collector code

run-prompt

Runs a Claude AI prompt against the repository and collects the results. Supports optional JSON schema enforcement for structured output. Use cases include feature flag detection, documentation quality analysis, and architecture pattern detection.

claude ai llm code analysis pattern detection anthropic
Book a demo

How Collectors Fit into Lunar

Lunar watches your code and CI/CD systems to collect SDLC data from config files, test results, IaC, deployment configurations, security scans, and more.

Collectors are the automatic data-gathering layer. They extract structured metadata from your repositories and pipelines, feeding it into Lunar's centralized database where guardrails evaluate it to enforce your engineering standards.

Learn How Lunar Works
1
Collectors Gather Data This Integration
Triggered by code changes or CI pipelines, collectors extract metadata from config files, tool outputs, test results, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards
Real-time feedback in PRs and AI workflows

Example Collected Data

This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:

{ } component.json Component JSON
{
  "ai": {
    "code_reviewers": [
      {
        "tool": "claude",
        "check_name": "Claude Code Review",
        "detected": true,
        "last_seen": "2024-01-14T08:00:00Z"
      }
    ],
    "instructions": {
      "all": [
        {
          "path": "CLAUDE.md",
          "dir": ".",
          "filename": "CLAUDE.md",
          "lines": 85,
          "bytes": 3200,
          "is_symlink": true,
          "symlink_target": "AGENTS.md"
        }
      ]
    },
    "native": {
      "claude": {
        "instruction_file": {
          "exists": true,
          "path": "CLAUDE.md",
          "lines": 85,
          "bytes": 3200,
          "is_symlink": true,
          "symlink_target": "AGENTS.md"
        },
        "cicd": {
          "cmds": [
            {
              "cmd": "claude -p --output-format json --allowedTools Bash(git*) Read 'review this PR'",
              "tool": "claude",
              "version": "1.0.20",
              "allowed_tools": "Bash(git*) Read"
            }
          ]
        },
        "code_review": {
          "ran": true,
          "findings_count": 3,
          "findings": [
            {
              "severity": "warning",
              "file": "src/auth.ts",
              "line": 42,
              "message": "Token expiry not checked before use"
            }
          ]
        }
      }
    }
  }
}

Configuration

Configure this collector in your lunar-config.yml.

Inputs

Input Required Default Description
path Required JSON component path for run-prompt results (e.g., ".code_patterns.feature_flags")
prompt Required Prompt for Claude to run on the component repository (run-prompt only)
json_schema Required Optional JSON schema for structured output in run-prompt

Secrets

This collector requires the following secrets to be configured in Lunar:

Secret Description
GH_TOKEN GitHub token for API access (required for code-reviewer check-runs query)
ANTHROPIC_API_KEY Anthropic API key for Claude authentication (required for run-prompt and run-code-review)

Documentation

View on GitHub

Claude Collector

Detect Claude code review activity, CI usage, instruction files, and run AI prompts against repository code.

Overview

This collector detects Claude Code Review on pull requests, captures Claude CLI invocations in CI pipelines, discovers CLAUDE.md instruction files, and can run custom Claude AI prompts or code review against PRs.

Code reviewer data writes to normalized ai.code_reviewers[]; instruction files write to both ai.native.claude.instruction_file and ai.instructions.all[] via array append. CI data writes to ai.native.claude.cicd, run-code-review to ai.native.claude.code_review, and run-prompt to a user-configurable path.

Collected Data

This collector writes to the following Component JSON paths:

Path Type Description
.ai.code_reviewers[] array append Claude Code Review detection entry with check name and timestamp
.ai.instructions.all[] array append CLAUDE.md entry appended to the normalized instruction files array
.ai.native.claude.instruction_file object CLAUDE.md file: existence, path, line count, byte size, symlink status
.ai.native.claude.cicd.cmds[] array Claude CLI invocations in CI: command string, version, allowed/disallowed tools, MCP config
.ai.native.claude.code_review object Claude CLI review mode results: findings count, severity, affected files
{path} (configurable) any Claude prompt response from run-prompt, optionally conforming to a JSON schema

Collectors

This integration provides the following collectors:

Collector Hook Description
code-reviewer code (PRs only) Detects Claude Code Review check-runs on pull requests
run-code-review code (PRs only) Runs Claude CLI in review mode against PR diffs
instruction-file code Discovers CLAUDE.md instruction files with metadata and symlink status
cicd ci-after-command (binary: claude) Captures Claude CLI invocations in CI with flag extraction
run-prompt code Runs a Claude AI prompt against the repo and collects structured results

Installation

Code Review Detection

collectors:
  - uses: github://earthly/lunar-lib/collectors/claude@main
    on: ["domain:your-domain"]
    include: [code-reviewer]
    secrets:
      GH_TOKEN: "${{ secrets.GH_TOKEN }}"

Run Code Review (AI-Powered)

collectors:
  - uses: github://earthly/lunar-lib/collectors/claude@main
    on: ["domain:your-domain"]
    include: [run-code-review]
    secrets:
      ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"
      GH_TOKEN: "${{ secrets.GH_TOKEN }}"

CI Detection + Instruction Files

collectors:
  - uses: github://earthly/lunar-lib/collectors/claude@main
    on: ["domain:your-domain"]

Run Prompt (AI-Powered Analysis)

collectors:
  - uses: github://earthly/lunar-lib/collectors/claude@main
    on: ["domain:your-domain"]
    include: [run-prompt]
    with:
      path: ".code_patterns.feature_flags"
      prompt: "Find all feature flags in this repository and return them as a list"
    secrets:
      ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"

With JSON Schema Enforcement

collectors:
  - uses: github://earthly/lunar-lib/collectors/claude@main
    on: [backend]
    include: [run-prompt]
    with:
      path: ".code_patterns.lifecycle"
      prompt: "Analyze this codebase for graceful shutdown handling."
      json_schema: |
        {
          "type": "object",
          "properties": {
            "handles_sigterm": {"type": "boolean"},
            "shutdown_timeout_seconds": {"type": "number"},
            "files": {"type": "array", "items": {"type": "string"}}
          }
        }
    secrets:
      ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}"

Open Source

This collector is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.

View Repository

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 100+ 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