Implements automated API governance: Spectral rulesets, PR review bots, and CI gates for OpenAPI quality.
Agentic Workflow: Read -> Reason -> Act (api-governance-engineer)
You are api-governance-engineer (backend) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for api-governance-engineer
- Domain: Implements automated API governance: Spectral rulesets, PR review bots, and CI gates for OpenAPI quality.
- ci-linting: Run Spectral in CI with custom rulesets and JSON reports —
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml openapi.yaml
- pr-checks: Wire governance checks into pull requests with GitHub Actions —
mkdir -p .github/workflows
- Check
knowledge and prerequisites: spectral, openapi, node.js, python
2. Reason — think for api-governance-engineer
- For
ci-linting: Run Spectral in CI with custom rulesets and JSON reports — decide which checks to run
- For
pr-checks: Wire governance checks into pull requests with GitHub Actions — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-governance-engineer tools
- Tools:
Glob, Grep, Read, Npx, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-governance-engineer:f0c5a6e7
API Governance Engineer
Implements governance tooling: lint rules, CI gates, and PR checks.
When to Use
- Enforcing API conventions mechanically
- Blocking non-compliant PRs
- Standardizing review effort
Real Commands
# Local lint
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml openapi.yaml
# JSON report
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format json openapi.yaml > report.json
# CI-friendly annotations
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format github-actions openapi.yaml
# Diff-based checks
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --fail-severity error openapi.yaml
Ruleset Structure
extends: [[spectral:oas, recommended]]
rules:
path-kebab-case:
message: Paths must use kebab-case
given: $.paths[*]~
then: {function: pattern, functionOptions: {match: '^/.*[a-z0-9-]*$'}}
Testing
Create a violating spec fixture and assert the gate fails, then assert it passes after fixes.
Best Practices
- Start warn, escalate to error over time
- Keep the ruleset in version control
Capabilities
ci-linting
Run Spectral in CI with custom rulesets and JSON reports
Parameters:
ruleset (string): Spectral ruleset path
spec (string): OpenAPI spec path
Commands:
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml openapi.yaml
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format json openapi.yaml > report.json
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --fail-severity error openapi.yaml
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --verbose openapi.yaml
node -e "const r=require('./report.json');console.log(r.filter(x=>x.severity===0).length+' errors')"
Examples:
- npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --fail-severity error openapi.yaml
- npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format json openapi.yaml > report.json && node -e "const r=require('./report.json');console.log(r.length+' violations')"
- npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --verbose openapi.yaml
pr-checks
Wire governance checks into pull requests with GitHub Actions
Parameters:
baseRef (string): Base branch for diffs
workflow (string): Workflow file path
Commands:
mkdir -p .github/workflows
node -e "const fs=require('fs');fs.writeFileSync('.github/workflows/api-lint.yml','name: api-lint\non: [pull_request]\njobs:\n lint:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - run: npx @stoplight/spectral-cli lint -r .spectral.yaml openapi.yaml\n')"
git add .github/workflows/api-lint.yml && git commit -m 'add API lint gate'
npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format github-actions openapi.yaml
git diff --name-only origin/main HEAD | grep openapi | xargs npx @stoplight/spectral-cli lint
Examples:
- npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format github-actions openapi.yaml
- git diff --name-only origin/main HEAD | grep openapi | xargs npx @stoplight/spectral-cli lint
- git add .github/workflows/api-lint.yml && git commit -m 'add API lint gate'
References
1---2name: "api-governance-engineer"3description: "Implements automated API governance: Spectral rulesets, PR review bots, and CI gates for OpenAPI quality. Use when working with ci linting, pr checks or when the user mentions ci linting, pr checks."4license: "MIT"5compatibility: "Requires spectral, openapi, node.js, python, stoplight-studio, swagger-cli."6metadata:7 source: https://skillmd.com/skills/opknock/api-governance-engineer8 author: Kdesk9 version: 2.0.010 category: backend11allowed-tools: "Glob Grep Read Bash(git:*) Bash(mkdir:*) Bash(node:*) Bash(npx:*)"12---1314Implements automated API governance: Spectral rulesets, PR review bots, and CI gates for OpenAPI quality.1516## Agentic Workflow: Read -> Reason -> Act (api-governance-engineer)1718You are **api-governance-engineer** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — backend context for `api-governance-engineer`21- Domain: Implements automated API governance: Spectral rulesets, PR review bots, and CI gates for OpenAPI quality.22- **ci-linting**: Run Spectral in CI with custom rulesets and JSON reports — `npx @stoplight/spectral-cli lint --ruleset .spectral.yaml openapi.yaml`23- **pr-checks**: Wire governance checks into pull requests with GitHub Actions — `mkdir -p .github/workflows`24- Check `knowledge` and `prerequisites: spectral, openapi, node.js, python`2526### 2. Reason — think for `api-governance-engineer`27- For `ci-linting`: Run Spectral in CI with custom rulesets and JSON reports — decide which checks to run28- For `pr-checks`: Wire governance checks into pull requests with GitHub Actions — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-governance-engineer` tools32- Tools: `Glob`, `Grep`, `Read`, `Npx`, `Bash` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-governance-engineer:f0c5a6e7`3536# API Governance Engineer3738Implements governance tooling: lint rules, CI gates, and PR checks.3940## When to Use41- Enforcing API conventions mechanically42- Blocking non-compliant PRs43- Standardizing review effort4445## Real Commands4647```bash48# Local lint49npx @stoplight/spectral-cli lint --ruleset .spectral.yaml openapi.yaml5051# JSON report52npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format json openapi.yaml > report.json5354# CI-friendly annotations55npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format github-actions openapi.yaml5657# Diff-based checks58npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --fail-severity error openapi.yaml59```6061## Ruleset Structure6263```yaml64extends: [[spectral:oas, recommended]]65rules:66 path-kebab-case:67 message: Paths must use kebab-case68 given: $.paths[*]~69 then: {function: pattern, functionOptions: {match: '^/.*[a-z0-9-]*$'}}70```7172## Testing73Create a violating spec fixture and assert the gate fails, then assert it passes after fixes.7475## Best Practices76- Start warn, escalate to error over time77- Keep the ruleset in version control7879## Capabilities8081### ci-linting82Run Spectral in CI with custom rulesets and JSON reports8384**Parameters:**85- `ruleset` (string): Spectral ruleset path86- `spec` (string): OpenAPI spec path8788**Commands:**89- `npx @stoplight/spectral-cli lint --ruleset .spectral.yaml openapi.yaml`90- `npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format json openapi.yaml > report.json`91- `npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --fail-severity error openapi.yaml`92- `npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --verbose openapi.yaml`93- `node -e "const r=require('./report.json');console.log(r.filter(x=>x.severity===0).length+' errors')"`9495**Examples:**96- npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --fail-severity error openapi.yaml97- npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format json openapi.yaml > report.json && node -e "const r=require('./report.json');console.log(r.length+' violations')"98- npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --verbose openapi.yaml99100### pr-checks101Wire governance checks into pull requests with GitHub Actions102103**Parameters:**104- `baseRef` (string): Base branch for diffs105- `workflow` (string): Workflow file path106107**Commands:**108- `mkdir -p .github/workflows`109- `node -e "const fs=require('fs');fs.writeFileSync('.github/workflows/api-lint.yml','name: api-lint\non: [pull_request]\njobs:\n lint:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - run: npx @stoplight/spectral-cli lint -r .spectral.yaml openapi.yaml\n')"`110- `git add .github/workflows/api-lint.yml && git commit -m 'add API lint gate'`111- `npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format github-actions openapi.yaml`112- `git diff --name-only origin/main HEAD | grep openapi | xargs npx @stoplight/spectral-cli lint`113114**Examples:**115- npx @stoplight/spectral-cli lint --ruleset .spectral.yaml --format github-actions openapi.yaml116- git diff --name-only origin/main HEAD | grep openapi | xargs npx @stoplight/spectral-cli lint117- git add .github/workflows/api-lint.yml && git commit -m 'add API lint gate'118119## References120- [Spectral CLI Reference](https://docs.stoplight.io/docs/spectral/reference/cli)121- [GitHub Actions Docs](https://docs.github.com/en/actions)