Pre Commit Ci Skip Empty + Git Collector
Enforce Pre Commit Ci Skip Empty using data collected by Git Collector. Automatically check devex build and ci standards on every PR.
How Git Collector Powers This Guardrail
The Git Collector gathers metadata from your code analysis systems. This data flows into Lunar's Component JSON, where the Pre Commit Ci Skip Empty 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 Git Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/git@v1.0.5
# with: ...
# Step 2: Enable the Git Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/git@v1.0.5
include: [pre-commit-ci-skip-empty]
# with: ...
What Git Collector Collects
This collector gathers the following data that the Pre Commit Ci Skip Empty guardrail evaluates.
pre-commit
Scans the repository for a pre-commit configuration file at
.pre-commit-config.yaml (or .yml variant). Parses the YAML to extract
the configured repos[] (each with repo, rev, hooks[]), a
flattened list of hook IDs, and the optional ci.skip list. Writes
structured data to .git.pre_commit.
gitattributes
Detects .gitattributes in the repository root. Parses each rule to
classify patterns by attribute (text/eol for EOL normalization,
filter=lfs for Git LFS, binary for binary patterns,
export-ignore for archive exclusion). Writes to .git.attributes.
gitmodules
Detects .gitmodules in the repository root. Parses each
[submodule "<name>"] block to extract path, url, and the
optional branch field (set when a submodule tracks a floating
ref via git submodule update --remote). Writes to
.git.submodules.
Example Data Flow
Here's an example of the data that Git Collector writes to the Component JSON, which Pre Commit Ci Skip Empty then evaluates.
{
"git": {
"pre_commit": {
"valid": true,
"path": ".pre-commit-config.yaml",
"repos": [
{
"repo": "https://github.com/pre-commit/pre-commit-hooks",
"rev": "v4.5.0",
"hooks": [
{"id": "trailing-whitespace"},
{"id": "end-of-file-fixer"}
]
},
{
"repo": "https://github.com/gitleaks/gitleaks",
"rev": "v8.18.0",
"hooks": [
{"id": "gitleaks"}
]
}
],
"hook_ids": ["trailing-whitespace", "end-of-file-fixer", "gitleaks"],
"hook_count": 3,
"repo_count": 2,
"ci_skip": [],
"all_pinned": true
},
"attributes": {
"valid": true,
"path": ".gitattributes",
"rules_count": 8,
"lfs_patterns": ["*.psd", "*.zip"],
"binary_patterns": ["*.exe"],
"eol_normalized": true,
"export_ignore_patterns": [".github/", "tests/"]
},
"submodules": {
"valid": true,
"path": ".gitmodules",
"modules": [
{
"name": "vendor/foo",
"path": "vendor/foo",
"url": "https://github.com/example/foo.git",
"branch": null
},
{
"name": "vendor/bar",
"path": "vendor/bar",
"url": "https://github.com/example/bar.git",
"branch": "main"
}
]
}
}
}
Configuration Options
Git Collector Inputs
| Input | Required | Default | Description |
|---|---|---|---|
pre_commit_paths |
Optional |
.pre-commit-config.yaml,.pre-commit-config.yml
|
Comma-separated list of pre-commit config file paths to check (first match wins) |
gitattributes_paths |
Optional |
.gitattributes
|
Comma-separated list of .gitattributes paths to check (first match wins) |
gitmodules_paths |
Optional |
.gitmodules
|
Comma-separated list of .gitmodules paths to check (first match wins) |
Git Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
secret_scan_hook_ids |
Optional |
gitleaks,detect-secrets,trufflehog,detect-aws-credentials,detect-private-key
|
Comma-separated list of pre-commit hook IDs that count as secret scanners |
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.