Claude Collector
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.
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.
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[].
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.
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).
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.
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.
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 →Example Collected Data
This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:
{
"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 GitHubClaude 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.
Common Use Cases
Explore guardrails that use data from Claude Collector.
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.