Claude Guardrails
Enforces Claude-specific standards: CI safety flags, structured output, and CLAUDE.md symlink compatibility alongside AGENTS.md.
claude to your lunar-config.yml:uses: github://earthly/lunar-lib/policies/claude@v1.0.5
Included Guardrails
This policy includes 3 guardrails that enforce standards for your devex build and ci.
cli-safe-flags
Ensures Claude CLI invocations in CI do not use dangerous permission-bypassing flags. Flags like --dangerously-skip-permissions remove safety guardrails that prevent the AI from executing arbitrary code without human approval.
cli-structured-output
Ensures Claude CLI invocations in CI headless mode use structured JSON output (--output-format json) instead of plain text. JSON output makes AI automation deterministic and parseable.
symlinked-aliases
Verifies that CLAUDE.md exists as a symlink to AGENTS.md. Claude Code does not support the AGENTS.md filename natively, so a symlink is required for compatibility. Reads from ai.native.claude.instruction_file to check symlink status.
How Guardrails Fit into Lunar
Lunar guardrails define your engineering standards as code. They evaluate data collected by integrations and produce pass/fail checks with actionable feedback.
Policies support gradual enforcement—from silent scoring to blocking PRs or deployments—letting you roll out standards at your own pace without disrupting existing workflows.
Learn How Lunar Works →Example Evaluated Data
This policy evaluates structured metadata from the Component JSON. Here's an example of the data it checks:
{
"ai": {
"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"
}
]
}
}
}
}
}
Required Integrations
This policy evaluates data gathered by one or more of the following integration(s).
Make sure to enable them in your lunar-config.yml.
Configuration
Configure this policy in your lunar-config.yml.
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
dangerous_flags
|
Optional |
--dangerously-skip-permissions,--allow-dangerously-skip-permissions
|
Comma-separated dangerous flags for Claude CLI |
Documentation
View on GitHubClaude Guardrails
Claude-specific CI safety and conventions guardrails.
Overview
This policy enforces Claude-specific standards: CI safety flags, structured output, and CLAUDE.md symlink compatibility. It validates that Claude CLI invocations do not use dangerous flags, use structured JSON output, and that CLAUDE.md exists as a symlink to AGENTS.md.
Policies
| Policy | Severity | Description |
|---|---|---|
cli-safe-flags |
error | Claude CLI must not use --dangerously-skip-permissions or similar flags |
cli-structured-output |
warning | Claude CLI in CI should use --output-format json |
symlinked-aliases |
warning | CLAUDE.md must exist as a symlink to AGENTS.md |
Required Data
| Path | Provided By | Description |
|---|---|---|
.ai.native.claude.instruction_file |
claude collector |
CLAUDE.md file detection with symlink status |
.ai.native.claude.cicd.cmds[] |
claude collector |
Claude CLI invocations captured in CI |
Installation
collectors:
- uses: github://earthly/lunar-lib/collectors/claude@main
on: ["domain:your-domain"]
policies:
- uses: github://earthly/lunar-lib/policies/claude@main
enforcement: report-pr
Examples
Passing
Claude CLI using safe flags and structured output:
{
"ai": {
"native": {
"claude": {
"cicd": {
"cmds": [
{
"cmd": "claude -p --output-format json --allowedTools Read 'review this PR'",
"tool": "claude"
}
]
}
}
}
}
}
Failing
Claude CLI using dangerous permission-bypassing flag:
{
"ai": {
"native": {
"claude": {
"cicd": {
"cmds": [
{
"cmd": "claude --dangerously-skip-permissions -p 'deploy to prod'",
"tool": "claude"
}
]
}
}
}
}
}
Remediation
- cli-safe-flags: Remove
--dangerously-skip-permissionsfrom Claude CI invocations. Use--allowedToolsto grant specific tool access instead. - cli-structured-output: Add
--output-format jsonto Claude CLI invocations in CI. - symlinked-aliases: Create
ln -s AGENTS.md CLAUDE.mdso Claude Code can find the instruction file.
Open Source
This policy is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.
Common Use Cases
Explore how individual guardrails work with specific integrations.
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.