# API Governance Engineer

> 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.

- Skill: `opknock/api-governance-engineer` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-governance-engineer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-governance-engineer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-governance-engineer

---


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

```bash
# 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

```yaml
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
- [Spectral CLI Reference](https://docs.stoplight.io/docs/spectral/reference/cli)
- [GitHub Actions Docs](https://docs.github.com/en/actions)

