review-linter-rule
Skill25 starsChanged 5 months agoMITView on GitHub
Review a proposed or generated Azure Policy Linter rule against the repo''s design conventions and common AI-fingerprint failure modes. High-signal, low-noise - only flags things that actually matter. Triggers: "review this linter rule", "check the rule", "review the rule before I commit", "audit this rule".
In this repository4 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- implement-linter-ruleSkill
- sanity-check-linterSkill
- triage-linter-ruleSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 10 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Read these before reviewing anything:
- Distinctive: line 59
Check every user-facing string (title, description format, doc body, suggestions) against this list:
- Very specific: line 79
sealed classandapplyToDerivedTypes: false: Every rule should be sealed. - Very specific: line 82
nullvs[]collection handling: Verify the rule treats null (absent property) differently from an empty array (explicitly set to empty). - Distinctive: line 84
One finding per independent problem: If the rule checks multiple unrelated properties and aggregates them into one finding (especially via …
- Very specific: line 86
.ToLower()/.ToUpper()for case-insensitive comparison: Use StringComparison.OrdinalIgnoreCase overloads. - Distinctive: line 126
If a check group has no findings, list it with "No findings." Don't pad.
- Distinctive: line 128
If the whole rule passes, say "Rule passes review.
- Very specific: line 133
Don't flag things that compilers, analyzers, or .editorconfig already catch.
- Distinctive: line 134
Don't flag formatting (whitespace, brace placement, import ordering).
- Distinctive: line 135
Don't restate principles the rule already follows.
- Distinctive: line 136
Don't speculate about intent.
- Distinctive: line 137
Don't propose alternative implementations beyond a one-line "Fix:" - the implement skill owns implementation.
- Distinctive: line 138
When in doubt, omit. A clean review with three real findings is more valuable than a noisy review with thirty.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: Review a Policy Linter Rule
Review a single proposed or modified linter rule - its code, its tests, and its doc - and return a tight list of issues that genuinely matter. Optimize for signal: do not flag formatting nits, things compilers/analyzers catch, or principles that the canonical docs cover and the author is plainly aware of.
References
Read these before reviewing anything:
docs/linter-rule-design.md- what a good rule looks like. The review is largely an audit against this doc.docs/linter-architecture.md- how rules work in code. Reference for the contract, helpers, and where things live.
Related skills:
implement-linter-rule- produces the artifacts this skill reviews. Understanding its flow helps you spot where things tend to drift.
The things that matter most
- The rule must help a policy author do something about their policy. Every artifact - the finding's title, the description, the doc - has to help the author understand what was found, why it matters for their policy, and what to do about it. This is the lens for everything below.
- Coherence cascade. A rule's identity lives in ~10 places - class name, file path, namespace,
[RuleSet]attribute,identifier,RuleTitle,RuleDescriptionplaceholder count, doc filename, doc H1, doc metadata table. AI implementations reliably update some and forget others. Audit all of them. - AI-fingerprint tone failures. A separate cluster of failures recur because the model defaults to confident, abstract, exhaustive prose. Catch them by name (see the "Tone discipline check" below).
- Correct code can still be over-built. Review whether the complexity is proportional to the value and coverage gained, and whether the rule recreates functionality that belongs in the core linter.
Flow
- Read the rule's
.csfile, its test file, and its doc file. If any of the three is missing, that's the first finding - stop and report it. - Read
docs/linter-rule-design.mdif you haven't already in this session. The design doc is the source of truth for the design checks below; don't review from memory. - Work through the three check groups in order: coherence cascade -> tone discipline -> implementation. Stop and gather findings as you go; don't report them one at a time.
- Generalize each finding. Decide whether it is specific to one artifact or applies across the rule, its tests, its doc, sibling rules, or the whole change. Review every place where it applies before reporting it.
- Report findings in the format below. If a check group is clean, say so in one line - don't pad. If the rule passes everything, say so plainly.
Coherence cascade check
Walk the list. Any mismatch is a finding.
- Class name (PascalCase, matches
RuleTitlewith spaces removed). - File name (matches class name).
- File path (under the correct rule-set subfolder).
- Namespace - sits under
Microsoft.Azure.Policy.PolicyLinter.Core.Rules.<Folder>regardless of which project; matches the folder structure. [RuleSet("...")]attribute present for non-default rule sets, absent for default.identifierconstructor argument (kebab-case, matches doc filename exactly).RuleTitleconstant (matches doc H1 verbatim).RuleDescriptionconstant placeholder count matches the args passed toCreateXxx(...).- Doc filename (matches identifier exactly).
- Doc metadata table (identifier, category, severity, rule set all match what's in code).
Tone discipline check
Check every user-facing string (title, description format, doc body, suggestions) against this list:
- Invented categorical nouns. "Effect groups", "shapes", "buckets", "patterns" - terms that don't exist in Azure Policy documentation. Flag and propose either the existing taxonomy term or a prose description.
- Engine-mechanics digressions. "More efficient", "the engine still performs pattern matching", "avoids extra allocations." The policy author doesn't care. Flag.
- Speculative-mistake explanations. "Typically indicates a typo", "the author probably forgot to..." Don't speculate about author intent. Flag.
- Harsh verdicts. "Incorrectly cased", "wrong value", "invalid configuration." The author hasn't done anything wrong; the rule found a pattern. Flag.
- Branching descriptions. Single description format string with "missing X" / "missing Y" / "missing X and Y" fragments. Should be one finding per problem. Flag.
Mustoutside Error severity.Mustin class name, title, description, or doc with anything other thanSeverity.Error. Flag.- Awkward substitution. Pick a realistic value for each
{0}/{1}placeholder and read the description aloud. If it reads strangely with the substituted value (e.g. "The parameter reference 'myParam' does not..." vs the expected "...references parameter 'myParam'..."), flag it. - URLs or line breaks in description. Description is single-line, no URLs. Flag.
- Description longer than 400 characters. Aim for 150-300; 400 is a hard ceiling. Flag.
- Comments that take dependencies on other code.
// other rules handle that caseand similar. Flag.
Implementation check
The implementation checks worth running are the ones that catch real bugs:
- Engine-code modification. The rule must only touch its own
.cs, its test, and its doc. Files added or modified undersrc/PolicyLinter.Core/Expressions/,Parsing/,Extensions/,Metadata/, or other root engine paths are a red flag - the logic belongs in the rule. Flag as Error. - Missing core functionality recreated inside the rule. Flag generic parsing, policy evaluation, applicability, or other reusable core behavior implemented privately by a rule. Utility methods specific to the rule are fine.
- Disproportionate complexity. A correct and tested rule can still be over-built. Flag complexity that is disproportionate to the value or coverage gained, and state the simpler check and what it would miss.
sealed classandapplyToDerivedTypes: false. Every rule should besealed. Constructor should passapplyToDerivedTypes: falseunless the rule has a documented reason to walk derived expression types. Both are easy to miss; analyzers don't catch either.- XML documentation shape. Class has a real
<summary>describing what the rule checks - never/// <inheritdoc/>.Evaluateuses<inheritdoc/>. Constructor uses the standardInitializes a new instance of the <see cref="..."/> class.form. HasLiteralValueguard andHasSimpleParameterizedValuecompanion. Any read ofProperty.Valuethat doesn't go throughHasLiteralValuefirst will misfire on[parameters('...')]values. Inversely, rules that intentionally handle parameterized values should useHasSimpleParameterizedValue, not regex on the raw string. Flag either failure mode.nullvs[]collection handling. Verify the rule treatsnull(absent property) differently from an empty array (explicitly set to empty). Skipping on both is a common bug.- Emit target specificity.
CreateError/CreateWarning/CreateInformationalshould be called with the most specific expression node, not the parent. Diagnostic line numbers and JSON paths come from the passed node. Flag if the rule passes a parent node when it could pass a child. - One finding per independent problem. If the rule checks multiple unrelated properties and aggregates them into one finding (especially via a branching description), flag - should be one per problem.
- Regex on template language expressions. Any use of
Regexto detect or parse[...]expressions. UseExpressionEngine.IsLanguageExpression()/ExpressionsEngine.ParseLanguageExpression(). Flag. .ToLower()/.ToUpper()for case-insensitive comparison. UseStringComparison.OrdinalIgnoreCaseoverloads. Flag.- Local allocation of allowlist sets. Static allowlists belong as
private static readonly HashSet<T>on the class, not allocated perEvaluatecall. Flag. - Reserved severity/category.
Severity.CriticalandCategory.Parsing/Linter/LinterRuleare reserved for engine-emitted findings. A rule using any of these is wrong. Flag as Error. - Non-default rule-set conventions. For non-default rule sets, set-specific conventions live in the existing rules in that set, not in the design doc. Skim 2-3 sibling rules and flag deviations from their patterns.
Test-specific checks
- At least one negative and one positive case. Negative = rule fires with exact-equivalence assertion; positive =
Should().BeEmpty(). HaveCount(N)beforeContainEquivalentOf. Without the count assertion, a test passes when the rule wrongly emits extra findings alongside the expected one. Flag if a test assertsContainEquivalentOfwithout first asserting count.- Assertion via
ContainEquivalentOfon a fullLinterOutputrecord. Substring or field-only assertions are brittle - they pass for the wrong reason. Flag if used. - Case-insensitivity, missing properties, and empty arrays each get a test when the rule's logic touches them.
- Test names follow
RuleTests_<RuleName>_<Case>for the default rule set;RuleTests_<RuleSet>_<RuleName>_<Case>for non-default rule sets. Flag any method that omits the rule-set segment for non-default rules, or that incorrectly includes it for default rules.
Doc-specific checks
- Required sections in order: metadata table, description, suggestions. Examples are optional and come last when they add value.
- Description is third-person declarative, suggestions are imperative second-person, examples are minimal fragments (not full policies).
- Description is useful to the policy author. By the end of the first sentence, the author should understand what is wrong with the policy. Flag descriptions that lead with detection mechanics, metadata predicates, expression-tree details, or the spec.
- Examples are labelled
ViolationandCorrect- notcompliant/non-compliant. The latter is bureaucratic AI-default phrasing. - Property names in doc body match the policy JSON's actual casing (camelCase:
endpointKind,allowedValues,existenceCondition). PascalCasing them is a recurring AI fingerprint that survives review because both readings parse. - Microsoft Learn links for documented Azure Policy concepts (operators, effects, parameter types). Their absence isn't always a finding, but flag if the doc restates concepts that have canonical pages.
- Depth matches the problem. A short rule deserves a short doc; padding to look thorough is a finding. So is compressing a judgment-heavy rule to look tidy.
- No CLI-invocation block ("to run this rule, do X") - that's the CLI's documentation problem, not the rule's. The metadata table already names the rule set.
Output format
Group findings by check group (Coherence cascade / Tone discipline / Implementation). Within each group:
[SEVERITY] <short label>
File: <path>:<line>
<one-line description of the issue>
Fix: <one-line concrete fix>Severities:
- Error - the rule is broken, ships wrong, or violates a hard project rule. Must fix.
- Warning - the rule deviates from convention in a way that will hurt readers or maintainers. Should fix.
- Suggestion - minor improvement; the rule works without it.
If a check group has no findings, list it with "No findings." Don't pad.
If the whole rule passes, say "Rule passes review. No findings." That's the whole output.
Hard rules
- Output is a tight, grouped list of findings or "Rule passes review. No findings." - nothing else.
- Don't flag things that compilers, analyzers, or
.editorconfigalready catch. - Don't flag formatting (whitespace, brace placement, import ordering).
- Don't restate principles the rule already follows.
- Don't speculate about intent. State what was found.
- Don't propose alternative implementations beyond a one-line "Fix:" - the implement skill owns implementation.
- When in doubt, omit. A clean review with three real findings is more valuable than a noisy review with thirty.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

