Communitygithub.com

パフォーマンスとスケール

ホットパス、リストエンドポイント、ページネーション、ループ内のデータアクセス、公開インターフェースやスキーマを扱う際に使用します。兆候としては、無制限のクエリ、N+1アクセス、レイテンシ予算の欠如、測定なしの最適化、多くの依存関係があるインターフェースの変更などがあります。キーワード: ページネーション、N+1、ハイラムの法則、パフォーマンス予算、バンドルサイズ。

パフォーマンスとスケール とは?

このスキルは、ソフトウェアシステムのパフォーマンスとスケーラビリティに焦点を当てています。パフォーマンスを予算化された機能として捉え、測定と制限を徹底し、今日の振る舞いが明日の契約となることを認識することの重要性を説きます。主な原則として、予算を設定して測定すること、最適化前に測定を行うこと、デフォルトでページネーションを実装すること、ループ内でのデータアクセス(N+1問題)を回避すること、そしてハイラムの法則に基づき公開インターフェースを契約として扱うこと(追加と非推奨化のみで、暗黙の変更は行わない)を挙げています。具体的な悪臭(スメル)とその修正方法を示したクイックリファレンステーブルも提供し、CIでの予算チェック(バンドルサイズ制限、クエリコスト制限)やレビューアによる判断(ページネーション、N+1回避)による実施(エンフォースメント)方法を提案しています。このスキルは、Claude CodeやCursor、CodexなどのAIエージェントがパフォーマンス関連のアドバイスやコードレビューを行う際に役立ちます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/lguidolin/agent-skills/tree/main/skills/performance-and-scale

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

パフォーマンスとスケール は何をしますか?

概要

パフォーマンスは予算のある機能です。測定し、制限し、今日の振る舞いが明日の契約になることを尊重してください。システムは、設計したスループットでダウンすることはめったにありません。インデックスを張っていないクエリや、ページネーションを実装していないリストでダウンします。

原則

  • 予算を設定し、それに対して測定する。 レイテンシ目標(observability-and-slosのSLOに紐づく)とクライアント予算(例:バンドルサイズ)。予算を超える回帰はバグです。
  • 最適化する前に測定する。 データ(プロファイル、クエリプラン、トレース)を使って実際のボトルネックを見つけてから、コードを変更してください。推測による最適化は禁止です。
  • デフォルトでページネーションを実装する。 増加する可能性のあるリストはすべて、上限付きのページサイズでページネーションします。無制限の結果セットはレイテンシとサービス拒否の危険をもたらします。
  • N+1アクセスパターンに注意する。 ループ内でデータを取得することは、最も一般的なスケーラビリティ障害です。代わりにバッチ処理か結合を使用してください(このスタックでは、行ごとの解決ではなく、GraphQLレイヤーの先行読み取り/DataLoaderを使用します)。
  • ハイラムの法則は現実です。インターフェースの観察可能な振る舞いは、十分な数のコンシューマーがいる場合、そのすべてが誰かの依存契約になります。 これには、意図していなかった振る舞い(順序、null可能性、エラー形状、タイミング)も含まれます。公開インターフェース(特にAPI/スキーマ)は契約として扱ってください:サイレントに変更するのではなく、追加と非推奨化を行ってください。 graphql-contract-testingの契約テストは、あなたが選択した振る舞いを固定します。規律は、あなたが選択しなかった振る舞いを保護します。

クイックリファレンス

悪臭(スメル)修正方法
ループ内のクエリバッチ処理または結合、先行読み取りを使用
制限のないリストエンドポイント上限付きページネーションを追加
「測定なしで最適化させてくれ」最初にプロファイル、本当のボトルネックを見つける
フィールドの型/null可能性/順序の変更契約の変更 — 新しいものを追加し、古いものを非推奨化
レイテンシやバンドル目標がない予算を設定し、回帰をバグとして扱う

実施方法(エンフォースメント): 機械化可能なものはCIで予算をチェック(バンドルサイズ制限、クエリコスト制限)。ページネーションとN+1回避は、負荷テストとクエリプランレビューに基づくレビューアの判断に委ねられます。

完全な根拠:憲法第11条、engineering-constitution/references/engineering-constitution.mdにバンドルされています。

Individual skills in this repo

This repo contains 18 individual skills — each has its own dedicated page.

lguidolin/change-hygiene-and-code-craft

Use when writing or refactoring code, structuring a commit or PR, or deciding whether to abstract duplication. Symptoms — mixing reorg with logic changes, a PR doing several things at once, a file growing large, the second copy of similar code, or unsure whether to DRY something up.

lguidolin/cloud-delivery-aks

Use when deploying to Kubernetes or Azure Kubernetes Service (AKS), configuring cloud secrets, setting up progressive rollout/canary, per-PR ephemeral environments, or k8s health probes. Keywords — Kubernetes, AKS, Key Vault, Argo Rollouts, Flagger, canary, blue-green, liveness, readiness, PodDisruptionBudget, HPA, rollback, GHCR.

lguidolin/commit-history-rewrite

Use when an existing repository has messy commit history that needs to conform to conventional commits before adopting release-please, or when intermediate WIP/fixup/merge commits need to be cleaned up.

lguidolin/conventional-commits-and-releases

Use when committing, writing a commit message, opening a PR that will be squash-merged, or configuring automated versioning/changelogs. Keywords — conventional commits, release-please, semver, feat/fix/chore, breaking change, changelog.

lguidolin/defense-in-depth-security

Use when handling untrusted input, secrets, authentication/authorization, or dependencies — or threat-modeling a new surface. Keywords — STRIDE, threat model, least privilege, secrets management, supply chain, dependency scanning, input validation, audit log, defense in depth.

lguidolin/designing-before-building

Use when starting a feature, fixing a non-trivial bug, or about to write implementation code — before any code exists. Symptoms you need this: "this is simple, I'll just code it", reaching for the editor before a design is approved, or an idea that hasn't been turned into a spec and plan.

lguidolin/engineering-constitution

Use when starting work in a project that follows the engineering constitution, orienting to its rules, or deciding which engineering practice applies to a task — spec writing, commits, testing, security, deploys, database, or UI work.

lguidolin/graphql-contract-testing

Use when writing a GraphQL query/mutation that the UI and a test will share, or building route/schema contract or smoke tests. Symptoms — copying a query into a test, a test asserting on query text, schema change that didn't break the UI build, or RLS/permission drift. Keywords — graphql-codegen, typed document, contract test, route smoke test.

lguidolin/init-repo-CI

Use when setting up a new repository with conventional commits, release-please, and CI automation, or when retrofitting an existing repository that lacks automated versioning and PR validation workflows.

lguidolin/interface-craft-and-accessibility

Use when building or styling UI — components, layouts, forms, design tokens — or making accessibility decisions. Keywords — a11y, WCAG, keyboard navigation, focus state, contrast, design system, minimalist UI, component reuse, ARIA, semantic HTML.

lguidolin/merge-gates-and-automation

Use when setting up or changing CI, pre-push hooks, or a task runner, or deciding what must pass before merge. Symptoms — tempted to put authoritative checks only in a local hook, skip CI, bypass with --no-verify, or unsure what gates a merge vs. runs locally.

lguidolin/observability-and-slos

Use when adding logging, metrics, tracing, health checks, SLOs, or alerting — or when building a service surface that needs to be operable and debuggable. Keywords — structured logs, OpenTelemetry, correlation id, RED metrics, liveness, readiness, SLI, SLO, error budget, alerting.

lguidolin/postgres-postgraphile-rls-and-sql

Use when writing PostgreSQL, PostGraphile config, Row-Level Security policies, SQL schema files, or working on the Browser→App→PostGraphile→Postgres data path. Keywords — RLS, SECURITY DEFINER, search_path, pgSettings, grants, roles, GraphQL depth limit, query cost, statement_timeout, SQL file organization.

lguidolin/recording-decisions

Use when a design or architecture decision has been made and needs to be captured — writing a decision record or ADR, updating a decision index, noting a deferred idea, or superseding a past decision. Keywords — ADR, decision record, rationale, rejected alternatives, dependency index.

lguidolin/resilience-and-deploy-safety

Use when planning a deploy, designing a rollback, or responding to an incident or writing a postmortem. Keywords — deploy safety, rollback, immutable artifact, progressive delivery, canary, blast radius, incident response, blameless postmortem, error budget.

lguidolin/ship-it

Use when the user wants to ship work — push, PR, archive decision records, merge, and clean up. Handles the full lifecycle from committing final changes through post-merge cleanup including converting specs/plans to compact decision records.

lguidolin/tests-as-a-control

Use when writing or modifying tests, when a test breaks during a refactor, or when testing permission/role rules. Symptoms — tempted to edit a test to make it pass, testing only the happy path, a deny-test that started passing, flaky tests, or unsure what to assert.

lguidolin/zero-downtime-migrations

Use when changing a database schema where data must survive the change — adding/removing/renaming columns, constraints, indexes, or backfilling. Symptoms — a destructive migration bundled with a code deploy, a NOT NULL column with a backfill, a table-locking UPDATE, or a rename. Keywords — expand/contract, parallel change, backfill, NOT VALID, CREATE INDEX CONCURRENTLY, graphile-migrate.

関連スキル