

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# AI Agent Guide for RuboCop23RuboCop is a Ruby static code analyzer and formatter.4Before contributing, read [CONTRIBUTING.md](CONTRIBUTING.md) and the5[development docs](https://docs.rubocop.org/rubocop/development.html).67## Essential Commands89```bash10bundle exec rake # Full CI: codespell + doc syntax check + specs + self-lint11bundle exec rake spec # Run specs (Parser)12bundle exec rake prism_spec # Run specs (Prism parser)13bundle exec rake internal_investigation # RuboCop linting itself14bundle exec rubocop --only Department/CopName # Lint with a single cop15```1617Always run `bundle exec rake` before opening a PR.1819## Project Layout2021```22lib/rubocop/cop/<department>/<cop_name>.rb # Cop source23spec/rubocop/cop/<department>/<cop_name>_spec.rb # Cop spec24config/default.yml # Default configuration for every cop25changelog/ # Pending changelog entries (one per file)26lib/rubocop/cop/<department>.rb # Department module with `register_cop` directives for lazy loading (auto-updated by generator)27```2829Departments: `Bundler`, `Gemspec`, `Layout`, `Lint`, `Metrics`, `Migration`,30`Naming`, `Security`, `Style`, `InternalAffairs`.3132## Creating a New Cop3334Scaffold:3536```bash37bundle exec rake 'new_cop[Department/CopName]'38```3940This generates the source file, spec file, `config/default.yml` entry, and41a `register_cop` directive in the department module (`lib/rubocop/cop/<department>.rb`),42which registers the cop for lazy loading. After generation:43441. Update the description in `config/default.yml`.452. Implement the cop.463. Write specs.474. Add a changelog entry: `bundle exec rake changelog:new`.4849### Cop Class Structure5051```ruby52# frozen_string_literal: true5354module RuboCop55 module Cop56 module Style57 # One-line summary starting with a verb (e.g. "Checks for …", "Enforces …").58 # Additional detail paragraph(s) if needed.59 #60 # @safety61 # Explain why autocorrect may be unsafe, or delete this section.62 #63 # @example64 # # bad65 # bad_code66 #67 # # good68 # good_code69 #70 class MyCop < Base71 extend AutoCorrector7273 MSG = 'Use `#good_method` instead of `#bad_method`.'74 RESTRICT_ON_SEND = %i[bad_method].freeze7576 # @!method bad_method?(node)77 def_node_matcher :bad_method?, <<~PATTERN78 (send nil? :bad_method ...)79 PATTERN8081 def on_send(node)82 return unless bad_method?(node)8384 add_offense(node) do |corrector|85 corrector.replace(node, 'good_method')86 end87 end88 alias on_csend on_send89 end90 end91 end92end93```9495Key conventions:9697- **`RESTRICT_ON_SEND`** — list method names so `on_send` is only called for98 those methods (performance optimization). Required when using `on_send`.99- **`alias on_csend on_send`** — handle safe navigation (`&.`). Add this100 whenever you define `on_send`, unless the cop explicitly does not apply to101 safe navigation.102- **`alias on_numblock on_block`** and **`alias on_itblock on_block`** — handle103 numbered-parameter blocks (`_1`) and `it`-blocks. Add these whenever you104 define `on_block`.105- **`extend AutoCorrector`** — declare this when the cop provides autocorrect.106- **`def_node_matcher`** / **`def_node_search`** — DSL for AST pattern matching.107 Document with a `@!method` YARD tag above each matcher.108- **YARD `@example`** — every cop must have at least one `# bad` / `# good`109 example pair. Examples must be **valid Ruby syntax** (the CI doc-syntax check110 parses them).111- **Cop description** — the first line of the YARD comment must be a complete112 sentence starting with a verb and ending with a period.113114## Writing Specs115116```ruby117# frozen_string_literal: true118119RSpec.describe RuboCop::Cop::Style::MyCop, :config do120 it 'registers an offense when using `#bad_method`' do121 expect_offense(<<~RUBY)122 bad_method(foo)123 ^^^^^^^^^^^^^^^ Use `#good_method` instead of `#bad_method`.124 RUBY125126 expect_correction(<<~RUBY)127 good_method(foo)128 RUBY129 end130131 it 'does not register an offense when using `#good_method`' do132 expect_no_offenses(<<~RUBY)133 good_method(foo)134 RUBY135 end136end137```138139- **`expect_offense`** — `^` carets mark the offense range and must align140 exactly under the offending code. The message follows the last caret.141- **`expect_correction`** — expected source after autocorrect. Must follow142 `expect_offense` in the same example.143- **`expect_no_offenses`** — assert no violations.144- Use `%{variable}` in `expect_offense` heredocs to interpolate dynamic values.145- Use `_{variable}` for offense-range placeholders.146- Use RSpec metadata tags like `:ruby27`, `:ruby34` to set the target Ruby147 version for a test.148- Configuration: `let(:cop_config) { { 'EnforcedStyle' => 'bar' } }`.149150## Changelog Entries151152Every user-visible change needs a changelog entry:153154```bash155bundle exec rake changelog:fix # Bug fix156bundle exec rake changelog:new # New feature157bundle exec rake changelog:change # Changed behavior158```159160Format (single line):161162```163* [#123](https://github.com/rubocop/rubocop/issues/123): Description. ([@username][])164```165166- Must end with `([@username][])`.167- `spec/project_spec.rb` validates the format in CI.168- Skip the changelog only for purely internal changes (refactors with no169 user-visible effect).170171## PR and Commit Conventions172173- Prefix commit messages with `[Fix #N]` when an issue exists.174- Each distinct fix belongs in its own logical commit. When a PR bundles several175 unrelated fixes (e.g. multiple cops, multiple false positives), give each one a176 separate commit with its own changelog entry rather than squashing them all177 into a single commit. Squash only commits that are part of the *same* fix.178- Run `bundle exec rake` and ensure it passes before pushing.179180## Common Mistakes1811821. **Missing `alias on_csend on_send`** — cops that check `on_send` must also183 handle safe navigation unless explicitly inapplicable.1842. **Missing `alias on_numblock on_block` / `alias on_itblock on_block`** —185 cops that check `on_block` must also handle numbered-parameter and186 `it`-parameter block forms.1873. **Invalid Ruby in YARD examples** — the CI `documentation_syntax_check` task188 parses every `@example` block. Use only valid syntax.1894. **Cop description not a sentence** — must start with a verb and end with a190 period (e.g. `# Checks for ...`, not `# Check for ...`).1915. **Missing `RESTRICT_ON_SEND`** — always define this when using `on_send`.1926. **Missing `@!method` YARD tag** — every `def_node_matcher` /193 `def_node_search` needs a `@!method` tag above it.1947. **Forgetting changelog entry** — CI will flag it.1958. **Manually creating changelog files** — use the rake tasks instead to get196 the correct filename format.1979. **Missing `extend AutoCorrector`** — required if the cop provides a198 `corrector` block in `add_offense`.19910. **Not running full `bundle exec rake`** — partial test runs miss lint and200 doc-syntax failures.20111. **Hardcoding node types instead of using node pattern matchers** — prefer202 `def_node_matcher` over manual `node.type == :send` checks.20312. **Not testing both `send` and `csend`** — if you alias `on_csend`, write204 specs that cover the `&.` operator.205
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 201k | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| aaif-goose/gooseAGENTS.md · 53k | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 8 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| deepseek-ai/deepseek-harnessnative/landlock-run/AGENTS.md · 104k | AGENTS.md | setupteststylearch+3 | 100/100 | today | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 68k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 13 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | today | |
| vllm-project/vllmAGENTS.md · 89k | AGENTS.md | setuptestlint-formatstyle+5 | 100/100 | 14 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/rubocop-rubocop-agents)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.