agentleFS
Microsoft AzureKnown publisherAzure/azure-openapi-validator/.github/copilot-instructions.md

azure-openapi-validator

Copilot instructions53 starsChanged 5 years agoMITView on GitHub

This is azure-openapi-validator (aka LintDiff), a linter for Azure OpenAPI specifications. It is an extension of AutoRest and supports Spectral lint rule format. The repository contains automated linter rules that apply to API specs in the azure-rest-api-specs repository. This is a monorepo managed by Rush.js with the following main packages:

  • Installs packages

The file

Show its rules and text

We split this copilot-instructions.md into the rules it gives an agent

19 rules. About 0 are common, 10 are distinctive, and 9 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.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Ensure branch is based on up-to-date main

    line 56
  2. Very specific:

    Run rush prep - this will execute all necessary checks

    line 57
  3. Very specific:

    If adding/modifying rules, run rush regen-ruleindex to update docs/rules.md

    line 58
  4. Very specific:

    Run rush change and follow prompts to generate changelog entries

    line 59
  5. Distinctive:

    Add the new rule with appropriate severity and documentation

    line 63
  6. Very specific:

    Add a label to your PR in the format test-<RuleName> to trigger the staging-lint check pipeline

    line 64
  7. Distinctive:

    Verify the rule works correctly by checking the staging-lint check results

    line 65
  8. Very specific:

    Import helpers from tslib (set noEmitHelpers: true, importHelpers: true)

    line 76
  9. Distinctive:

    Use existing libraries when possible

    line 83
  10. Distinctive:

    Prefer clear, descriptive variable names

    line 84
  11. Very specific:

    Important: After calling Workspace.resolveRef(), always check both !source and !source.value since the function's return type is …

    line 87
  12. Distinctive:

    When writing validation rules:

    line 100
  13. Very specific:

    Follow existing rule patterns in packages/rulesets/src/

    line 104
  14. Very specific:

    Add a label to your PR in format test-<RuleName> (e.g., test-ProvisioningStateSpecifiedForLROPut)

    line 119
  15. Distinctive:

    Check the workflow results and linter-findings artifact to validate rule behavior

    line 122
  16. Distinctive:

    Follow instructions in CONTRIBUTING.md under "How to locally reproduce a LintDiff failure"

    line 137
  17. Very specific:

    All rules should have documentation in docs/ directory.

    line 149
  18. Distinctive:

    Create release PR with changelog

    line 164
  19. Distinctive:

    Verify deployment using CloudMine/Kusto queries

    line 167

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

GitHub Copilot Instructions for azure-openapi-validator

Project Overview

This is azure-openapi-validator (aka LintDiff), a linter for Azure OpenAPI specifications. It is an extension of AutoRest and supports Spectral lint rule format. The repository contains automated linter rules that apply to API specs in the azure-rest-api-specs repository.

Architecture

This is a monorepo managed by Rush.js with the following main packages:

  • packages/azure-openapi-validator/core - Core functionality (@microsoft.azure/openapi-validator-core)
  • packages/azure-openapi-validator/autorest - AutoRest extension (@microsoft.azure/openapi-validator)
  • packages/rulesets - Ruleset implementations (@microsoft.azure/openapi-validator-rulesets)
    • src/spectral/ - Spectral format rules
    • src/native/ - Native TypeScript rules
  • regression - Regression tests

Build and Test Commands

Prerequisites

  • Node.js >= 18.0.0 (some packages like rulesets require >= 20)
  • Rush.js (npm install -g @microsoft/rush)

Essential Commands

Build:

rush update    # Install dependencies
rush build     # Build all projects

Test:

rush test                                                    # Run all tests
npx jest --config packages/rulesets/jest.native.config.js  # Native tests only (in packages/rulesets)
npx jest --config packages/rulesets/jest.config.js         # Spectral tests only (in packages/rulesets)

Lint:

rush lint      # Run linter on all projects
rush lint:fix  # Auto-fix linting issues

Other:

rush prep              # Complete pre-PR workflow: update, build, lint, test, regen-ruleindex, change
rush regen-ruleindex   # Regenerate docs/rules.md after rule changes
rush change            # Generate Rush changelog entries
rush regression-test   # Run regression tests

Development Workflow

Before Submitting a PR

  1. Ensure branch is based on up-to-date main
  2. Run rush prep - this will execute all necessary checks
  3. If adding/modifying rules, run rush regen-ruleindex to update docs/rules.md
  4. Run rush change and follow prompts to generate changelog entries
  5. For significant changes, manually update changelog.md

Adding New Linter Rules

  1. Add the new rule with appropriate severity and documentation
  2. Add a label to your PR in the format test-<RuleName> to trigger the staging-lint check pipeline
  3. Verify the rule works correctly by checking the staging-lint check results
  4. Iterate on the rule based on validation results until it works as expected
  5. Once the PR is merged, the rule is automatically deployed and released

Coding Conventions

TypeScript

  • Target: ES2019
  • Module: CommonJS
  • Strict null checks enabled
  • No implicit any
  • Import helpers from tslib (set noEmitHelpers: true, importHelpers: true)

Code Style

  • Prettier configured as auto-formatter
    • No semicolons (semi: false)
    • Print width: 140 characters
  • ESLint enforced - all projects must pass rush lint with --max-warnings=0
  • Use existing libraries when possible
  • Prefer clear, descriptive variable names

Null Safety Pattern

Important: After calling Workspace.resolveRef(), always check both !source and !source.value since the function's return type is EnhancedSchema | undefined, and the value property can be undefined when the $ref target doesn't exist.

Example:

const source = Workspace.resolveRef(enhancedSchema, inventory)
if (!source || !source.value) {
  // Handle undefined case
  return
}
// Safe to use source.value

Rule Properties

When writing validation rules:

  • Provide clear error messages
  • Include documentation links
  • Set appropriate severity (error/warning/info)
  • Follow existing rule patterns in packages/rulesets/src/

Testing

  • Jest is used for testing
  • Spectral tests are in packages/rulesets/src/spectral/test/
  • Native tests are in packages/rulesets/src/native/tests/ and match *-test(s).ts
  • Coverage threshold: ≥80% statement coverage for src/spectral/functions/*.ts
  • Native tests use jest.native.config.js
  • Spectral tests use jest.config.js

Common Tasks

Testing Rules with Staging-Lint Check

The .github/workflows/staging-lint-checks.yaml workflow allows you to test specific rules:

  • Add a label to your PR in format test-<RuleName> (e.g., test-ProvisioningStateSpecifiedForLROPut)
  • You can also specify rules in the PR body: rules: RuleName1, RuleName2
  • The workflow runs selected rules against a subset of Azure REST API specs
  • Check the workflow results and linter-findings artifact to validate rule behavior

Running Locally from Source

See CONTRIBUTING.md section "How to run LintDiff locally from source"

Setting Rule to Staging Only (Legacy)

The stagingOnly: true property in Spectral rules still exists but the deployment process has evolved. For new rules, use the staging-lint check workflow (above) to validate before production deployment. See CONTRIBUTING.md section "How to set a Spectral rule to run only in staging" for details on the stagingOnly property.

Regenerating Rules Documentation

rush regen-ruleindex

This updates docs/rules.md with the current rules index.

Reproducing LintDiff Failures

Follow instructions in CONTRIBUTING.md under "How to locally reproduce a LintDiff failure"

Important Files

  • rush.json - Monorepo configuration
  • common/config/rush/command-line.json - Custom Rush commands
  • docs/rules.md - Generated index of all rules (regenerate with rush regen-ruleindex)
  • CONTRIBUTING.md - Detailed contribution guidelines (41KB+)
  • changelog.md - Project changelog

Documentation

All rules should have documentation in docs/ directory. When adding a new rule, create a corresponding .md file in docs/ with:

  • Rule description
  • Examples of violations
  • Examples of correct usage
  • Links to relevant Azure API guidelines

Dependencies

  • Rush.js uses pnpm (v8.15.7) as the underlying package manager (configured in rush.json)
  • Strict peer dependencies enabled
  • Node.js >= 18.0.0 supported by Rush (individual packages like rulesets may require >= 20)

Deployment

Changes merge to main deploy to staging LintDiff. For production deployment:

  1. Create release PR with changelog
  2. Tag release
  3. Build and publish to npm
  4. Verify deployment using CloudMine/Kusto queries

See CONTRIBUTING.md "How to deploy your changes" for detailed instructions.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.