AGENT SKILL

x-review-graphql

Validates GraphQL schema design, resolver implementation, security patterns, and observability for compliance with best practices.

License 许可
MIT
最近更新
2026-10-27
Stars
★ 0
Forks
1

01 前言 Front Matter

name
x-review-graphql
description
Validates GraphQL schema design, resolver implementation, security patterns, and observability for compliance with best practices.
allowed-tools
Read, Grep, Glob, Bash
argument-hint
[schema-file or resolver-name]
user-invocable
true
requires-capabilities
[]

02 资源文件 1

03 SKILL.md 正文

Global Output Policy

  • Language: English ONLY.
  • Tone: Technical, Direct, and Concise.
  • Efficiency: Remove all conversational fillers and greetings to save tokens.

Skill: GraphQL Schema & Resolver Review

Purpose

Review GraphQL schema design, resolver implementation, security patterns, and observability for compliance with best practices including Relay Connection spec, query complexity limiting, and N+1 prevention.

Activation Condition

Include this skill when the project uses GraphQL protocol (interfaces contains type: graphql).

Triggers

  • /x-review-graphql schema.graphqls -- review a specific schema file
  • /x-review-graphql TransactionResolver -- review a specific resolver
  • /x-review-graphql -- review all GraphQL schemas and resolvers

Parameters

Parameter Type Required Default Description
target String No (all) Schema file path or resolver class name

Prerequisites

  • GraphQL schema files (*.graphqls, *.gql) or code-first schema definitions exist
  • GraphQL framework dependency is configured
  • Resolver classes/functions are implemented

Workflow

Step 1 — Discover Schema Files

Scan for *.graphqls, *.gql, or code-first schema definitions:

  • List all types, queries, mutations, and subscriptions
  • Identify input types and custom scalars

Step 2 — Discover Resolvers

Scan for resolver classes/functions:

  • Map resolvers to schema types
  • Identify DataLoader usage

Step 3 — Validate Schema Design

Check each type/operation:

  • Naming conventions (PascalCase types, camelCase fields, UPPER_SNAKE_CASE enums)
  • Pagination patterns (Relay Connection spec)
  • Mutation input/payload design
  • Subscription lifecycle

Step 4 — Validate Resolver Patterns

Check implementation:

  • DataLoader for N+1 prevention
  • Complexity and depth limiting
  • Field-level authorization
  • Error handling

Step 5 — Validate Security

Check security patterns:

  • Authentication on entry points
  • Introspection disabled in production
  • No sensitive data in errors

Step 6 — Generate Report

Summarize findings as checklist:

  • List compliant items
  • List violations with file paths and line numbers
  • Suggest fixes for each violation

Schema Design Checklist (14 points)

Naming & Types (1-5)

  1. Types use PascalCase (Transaction, PaymentMethod)
  2. Fields use camelCase (transactionId, createdAt)
  3. Enums use UPPER_SNAKE_CASE (PAYMENT_APPROVED, PAYMENT_DENIED)
  4. Input types suffixed with Input (CreateTransactionInput)
  5. Mutation payloads suffixed with Payload (CreateTransactionPayload)

Query Design (6-9)

  1. Cursor-based pagination for lists (Relay Connection spec: edges, node, pageInfo, cursor)
  2. No nested queries deeper than 4 levels without justification
  3. Nullable vs non-null strategy consistent (non-null by default, nullable where absence is valid)
  4. Custom scalars for domain types (DateTime, Money, Email)

Mutation Design (10-12)

  1. Mutations accept single input argument (not multiple args)
  2. Mutation payloads include both result and errors fields (union type for errors)
  3. Idempotency key pattern for critical mutations (clientMutationId)

Subscription Design (13-14)

  1. Subscriptions have clear lifecycle (start, data, complete, error)
  2. Subscription filters prevent over-broadcasting (topic-based filtering)

Resolver Checklist (10 points)

Performance (15-19)

  1. DataLoader used for batch loading (N+1 prevention)
  2. Complexity analysis configured (max query complexity limit)
  3. Depth limiting configured (max depth 10-15)
  4. Field-level resolvers are lazy (not pre-loading unused fields)
  5. Database queries scoped to requested fields only (projection)

Security (20-22)

  1. Authentication on schema entry points (Query, Mutation, Subscription)
  2. Field-level authorization for sensitive data
  3. Introspection disabled in production

Error Handling (23-24)

  1. Errors follow GraphQL spec (errors array with message, locations, path, extensions)
  2. Domain errors use union types or extensions.code (not just string messages)

Observability Checklist (4 points)

  1. Trace spans per resolver execution
  2. Metrics: query complexity, execution time, error rate per operation
  3. Structured logging: operation name, variables (masked), duration
  4. No sensitive data in error messages, traces, or logs

Output Format

## GraphQL Review — [Schema/Change Description]

### Schema Quality: HIGH / MEDIUM / LOW
### Resolver Quality: HIGH / MEDIUM / LOW

### Schema Findings
1. [Finding with file, line, issue, fix]

### Resolver Findings
1. [Finding with file, line, issue, fix]

### Security Findings
1. [Finding with severity, issue, fix]

### Checklist Results
[Items that passed / failed / not applicable]

### Verdict: APPROVE / REQUEST CHANGES

Error Handling

Scenario Action
No GraphQL schema files found Report INFO: no GraphQL schemas discovered
N+1 detected without DataLoader REQUEST CHANGES with DataLoader example
Introspection enabled in production REQUEST CHANGES with configuration fix

Rules

  • REQUEST CHANGES if N+1 detected without DataLoader
  • REQUEST CHANGES if no query depth/complexity limiting
  • REQUEST CHANGES if introspection enabled in production config
  • REQUEST CHANGES if sensitive data exposed without field-level auth
  • Verify pagination follows Relay Connection spec

04 同仓库更多 Skills

review-bench
review-bench/edercnj_ia-dev-environment

x-parallel-eval

Detects and classifies file-collision risks between work units (tasks, stories, or epic phases) before parallel execution. Reads ## File Footprint blocks produced by x-task-plan / x-story-plan, applies the parallelism-heuristics knowledge pack (hard / regen / soft categories + hotspot overrides), and emits a collision matrix + serialization recommendation in Markdown (default) or JSON.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

parallelism-heuristics

Canonical catalog of file-collision heuristics for parallel task, story, and epic execution. Defines the File Footprint block format, the three Conflict Categories (hard / regen / soft), a hotspot list of high-contention paths, and the degrade-with-warning policy. Consumed by x-task-plan, x-story-plan, x-epic-map, x-parallel-eval, and x-dev-*-implement.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

x-watch-pr-ci

Polls a PR's CI checks and Copilot review status, blocking until checks complete or timeout. Returns one of 8 stable exit codes (SUCCESS=0, CI_PENDING_PROCEED=10, CI_FAILED=20, TIMEOUT=30, PR_ALREADY_MERGED=40, NO_CI_CONFIGURED=50, PR_CLOSED=60, PR_NOT_FOUND=70). Writes a versioned state-file for session resume.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

x-validate-docs

Documentation freshness gate: validates 6 dimensions (readme, api-specs, grpc-proto, adr, skill-docs, system-architecture) against code changes in a PR. Stack-aware — only validates targets declared/auto-detected from ProjectConfig.documentation.targets. Returns exit non-zero on staleness; produces structured report.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

x-update-system-architecture

Incrementally updates docs/architecture/system.md after an epic completes. Appends new entries to the Decision Log (§11) using x-internal-write-report --append (dedup by ## ID: marker) and surgically inserts component/integration changes into sections 1-10 via Edit. Idempotent: re-running with the same epic produces a byte-identical system.md.

★ 0
review-bench
review-bench/edercnj_ia-dev-environment

x-update-architecture

Incrementally updates the service architecture document with changes from architecture plans. Adds new components, integrations, flows, and ADR references without rewriting existing content. Use after implementation to keep architecture documentation current.

★ 0