Skip to content
Development
Skill

/gate-semantic

Tiered semantic analysis of changed code (rg → ast-grep → OpenGrep). Detects error-path bugs structural gates miss. Findings default to WARN. Internal — invoked by verify.

From plugin
specwright
1023 skills9 agents18 commands

Claude Code

$ npx -y skills add Obsidian-Owl/specwright --skill gate-semantic --agent claude-code

SKILL.md

gate-semantic.SKILL.md
name: gate-semantic
description: >-
  Tiered semantic analysis of changed code (rg → ast-grep → OpenGrep).
  Detects error-path bugs structural gates miss. Findings default to
  WARN. Internal — invoked by verify.
allowed-tools:
  - Read
  - Bash
  - Glob
  - Grep
  - Write

Gate: Semantic Analysis

Goal

Detect semantic bugs in changed code using symbolic pre-processing when available. For each candidate finding, localize it explicitly with premises, claims, and conclusion grounded in file:line evidence.

Inputs

  • `config.json` `gates.semantic` — categories, tools, optional `rulesDir`
  • `{repoStateRoot}/work/{selectedWork.id}/workflow.json` — selected work unit
  • Changed files via `git diff --name-only $(git merge-base HEAD <baseBranch>)`

Outputs

  • `{workDir}/evidence/semantic-report.md`
  • Gate status in the selected work's `workflow.json`

Constraints

**Scope (MEDIUM freedom):** Changed code files only. Skip markdown/JSON/YAML/config. No changed code → PASS.

**Tool tiers (LOW freedom):** Resolve from `gates.semantic.tools` config, fall back to PATH detection. Missing tools narrow scope — never FAIL or ERROR. Validate `sg` identity: `sg --version 2>&1 | grep -iq 'ast-grep'` (`/usr/bin/sg` from shadow-utils is a false positive).

| Tier | Tool | Adds | |------|------|------| | 0 | rg | Text-pattern extraction + LLM | | 1 | ast-grep (`sg`) | Structural JSON, metavariable capture | | 2 | OpenGrep | Cross-function taint (rules: config `rulesDir` or `.opengrep/rules/`) |

**Extraction (HIGH freedom):** Extract structural facts using highest available tier's tool. Feed facts (not raw files) to LLM. Tier 1: `sg scan <file> --json --rule <rule>` or `sg run --pattern '...' <file> --json` (avoid `--stdin`). Tier 2: `opengrep scan --config <rules-dir> --json <file>`.

**Categories (LOW freedom):**

| Category | Tier | Diagnostic question | |----------|------|-------------------| | error-path-cleanup | 0+ | Does any error path skip releasing an acquired resource? | | unchecked-errors | 0+ | Is any error-producing call's return value discarded? | | fail-open-handling (CWE-636) | 1+ | Does any catch block swallow, broaden, or ignore errors? | | error-data-leakage (CWE-209) | 1+ | Does any error response expose internals to the caller? | | resource-lifecycle | 2+ | Is any acquired resource not released on all exit paths? |

Categories requiring an unavailable tier are skipped with an INFO note. Sole owner of CWE-636 and CWE-209 analysis (transferred from gate-security to avoid duplicate findings).

**Verdict (LOW freedom):** Per `protocols/evidence.md#verdict-rendering`. All findings WARN by default. No findings = PASS. WARN-only = WARN. Any BLOCK = FAIL.

Tier 0 categories: **permanently WARN-only**. Tier 1+ may promote to BLOCK when: (1) ≥5 shipped units, (2) FP rate <10% per `evidence.md#verdict-rendering` calibration, (3) user opt-in via config `{"severity": "block"}`.

**Evidence report:** Tool availability, skipped categories with reason, each finding with category, file:line, tier/tool, severity, remediation.

Protocol References

  • `protocols/evidence.md#verdict-rendering` -- verdict rendering and calibration
  • `protocols/evidence.md` -- evidence storage
  • `protocols/state.md` -- gate status updates
  • `protocols/context.md` -- config and anchor doc loading

Failure Modes

| Condition | Action | |-----------|--------| | Disabled in config | sw-verify skips silently | | No changed code files | PASS | | No symbolic tools | Degrade to Tier 0 | | Tool missing at runtime | WARN, skip tier | | No calibration data | All findings WARN |

Read more
@obsidian-owl
Ships withspecwright

Craft quality software with AI discipline. Spec-driven development plugin for Claude Code and Opencode — quality gates, adversarial testing, and evidence capture.

1023 skills9 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
10
Star history of Obsidian-Owl/specwright on GitHub, a chart by star-history.com

Other skills on specwright.

gate-build

gate-build

Runs configured build and test commands in tiered order. Captures output as evidence per tier. Returns PASS, FAIL, WARN, or SKIP…

gate-security

gate-security

Detects leaked secrets, injection patterns, and sensitive data exposure across changed files. Uses real tooling when configured,…

gate-spec

gate-spec

Maps every acceptance criterion from the spec to implementation evidence and test evidence. Criteria without evidence fail. The…

gate-tests

gate-tests

Audits test quality — assertion strength, boundary coverage, mock discipline, error path testing. Delegates to the tester agent…

gate-wiring

gate-wiring

Detects unused exports, orphaned files, architecture layer violations, and circular dependencies across changed files. Delegates…

sw-adopt

sw-adopt

Explicitly adopt an existing work into the current worktree after validating live ownership, stale sessions, and branch…

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills11d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc13d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react2d252k
@facebook@facebookInstall Skill

Questions about gate-semantic.

Which coding agents can use gate-semantic?
gate-semantic installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.