Bring harmony to your pull requests.
Features · Installation · Quick Start · Configuration · Rules · Reporters · How It Works
Nomos evaluates PR metadata and diffs, then reports findings as message, warn, or fail.
It is designed for fast startup, minimal API calls, and clear configuration.
- Diff-driven by default with optional lazy diff fetching
- Built-in cache to avoid redundant GitHub API calls
- Parallel rule execution
- Built-in rules plus Ruby DSL for custom checks
- Multiple reporters: GitHub comment, console, JSON
- Strict mode for CI gating
Add to your Gemfile:
gem "nomos"Then install:
bundle installRun in CI or locally:
nomos runGITHUB_TOKEN(GitHub API token)GITHUB_REPOSITORY(e.g.owner/repo)GITHUB_EVENT_PATH(path to GitHub event JSON)
Local override:
NOMOS_REPOSITORYandNOMOS_PR_NUMBERifGITHUB_EVENT_PATHis not available
- name: Nomos
run: nomos run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Create nomos.yml:
version: 1
reporter:
github: true
console: true
performance:
concurrency: 4
cache: true
lazy_diff: true
timing: false
rules:
- name: no_large_pr
type: builtin.no_large_pr
params:
max_changed_lines: 800
- name: require_changelog
type: builtin.require_file_change
params:
patterns:
- CHANGELOG.md
- name: custom_rules
type: ruby.file
params:
path: .nomos/rules.rbPerformance notes:
- Cache file defaults to
.nomos/cache.json(override withperformance.cache_path) - Use
--no-cacheto disable cache and lazy diff for a single run
nomos run [--config PATH] [--strict] [--debug] [--no-cache] [--reporter github,console,json]
nomos init
nomos doctor
builtin.no_large_prbuiltin.require_file_changebuiltin.forbid_pathsbuiltin.require_labelsbuiltin.todo_guard
rule "no_debugger" do
changed_files.grep(/\.rb$/).each do |file|
if diff(file).include?("binding.pry")
fail "binding.pry detected", file: file
end
end
endAvailable DSL API:
Array of changed file paths.
rule "example_changed_files" do
changed_files.grep(/\.md$/).each do |file|
message "Docs updated", file: file
end
endUnified diff for a file (string; empty if unavailable).
rule "example_diff" do
if diff("lib/app.rb").include?("binding.pry")
fail "Debug hook found", file: "lib/app.rb"
end
endPR title string.
rule "example_pr_title" do
warn "Title should start with [chore]", file: "PR" unless pr_title.start_with?("[chore]")
endPR body string.
rule "example_pr_body" do
fail "PR body must include a checklist", file: "PR" unless pr_body.to_s.include?("- [ ]")
endPR number.
rule "example_pr_number" do
message "Reviewing PR ##{pr_number}"
endPR author login.
rule "example_pr_author" do
warn "First-time contributor", file: "PR" if pr_author == "new-contributor"
endArray of label names.
rule "example_pr_labels" do
fail "Missing security label", file: "PR" unless pr_labels.include?("security")
endRepository identifier (owner/repo).
rule "example_repo" do
message "Running in #{repo}"
endBase branch name.
rule "example_base_branch" do
warn "Target branch should be main", file: "PR" unless base_branch == "main"
endCI context hash.
rule "example_ci" do
fail "Missing CI provider info", file: "CI" unless ci["provider"]
endAdd informational finding.
rule "example_message" do
message "Heads up", file: "README.md", line: 1, code: "docs"
endAdd warning finding.
rule "example_warn" do
warn "Large change set", file: "PR", code: "size"
endAdd failure finding.
rule "example_fail" do
fail "Missing CHANGELOG entry", file: "CHANGELOG.md", code: "changelog"
end- Create
.nomos/rules.rband define one or morerule "name"blocks. - Register the file in
nomos.ymlunderruleswithtype: ruby.fileandparams.path: .nomos/rules.rb. - Run
nomos run(or your CI job) to verify the rule executes.
Example:
# .nomos/rules.rb
rule "require_docs_change" do
unless changed_files.any? { |file| file.start_with?("docs/") }
fail "Docs must be updated for this change", file: "docs/"
end
end# nomos.yml
rules:
- name: require_docs_change
type: ruby.file
params:
path: .nomos/rules.rb- GitHub comment reporter
- Console reporter
- JSON reporter (for post-processing)
- Load PR context from GitHub API or event payload
- Fetch changed files and patches (lazy diff optional)
- Run rules in parallel where safe
- Report findings to configured outputs
- Exit with CI-friendly status
bundle exec rspecMIT License. See LICENSE file for details.