Communitygithub.com

自己修復ルールエンジン

ユーザーの修正やプロジェクト固有の制約から学習し、永続的なルールセット(autofix.json)を維持することで、エージェントが継続的に適応し、セッションをまたいだ同じミスの繰り返しを排除します。

自己修復ルールエンジン とは?

このスキルは、AIエージェント(Claude Code、Cursor、Codexなど)向けの自己修正ルールエンジンです。ユーザーからの修正指示(「いいえ、こうしてください」「Xは絶対にしない」「常にYを使って」など)や `/learn` コマンド、バグ発見などのトリガーを検出し、その内容を `autofix.json` ファイルに永続的なルールとして記録します。タスク開始前には常にこのファイルを読み込み、ルール間の競合を解決(新しいルールが優先)した上で、制約として適用します。これにより、エージェントはセッションをまたいで同じ過ちを繰り返さず、プロジェクト固有のコーディング規約やユーザー好みに常に従うことができます。ルールはJSON配列として保存され、カテゴリ(STYLE、CODE、ARCH、TOOL、PROCESS、DATA、UX、OTHER)ごとに整理されます。重要なのは、既存のルールは決して削除せず、新しいルールを追加することで優先順位を管理する点です。このスキルは常にアクティブで、セッション開始時にロードされ、あらゆるタスクの前に参照される必要があります。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/BIGboss248/nextjs-wordpress/tree/HEAD/.agents/skills/self-repair

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

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

ドキュメント

自己修復 (自己修正ルールエンジン)

ユーザーの修正、プロジェクトの慣習、バグ修正を永続的なルールセットファイル (autofix.json) に記録する、自己修正型のメモリおよび学習エンジンです。これにより、エージェントは継続的に適応し、セッションをまたいだ同じミスの繰り返しを排除し、ユーザーの好みに厳密に従います。

なぜ機能するのか: AIエージェントは、セッションが新しくなるたびに同じデフォルトの仮定やスタイル上のエラーを繰り返す傾向があります。学習した知識を、厳密な優先順位(新しいルールが優先)を持つ命令的なバージョン管理されたJSONルールセットに外部化することで、エージェントは特定のユーザーとリポジトリに合わせたハードな境界を保持できます。


ストレージと設定

スキルは、以下の場所からルールセットファイルを検索します(優先順位順):

  1. .agents/autofix.json
  2. autofix.json (ワークスペースルート)
  3. .rules/autofix.json

新しいルールを追加する必要がある時点でこれらのファイルが存在しない場合、.agents/autofix.json(またはプロジェクトの慣習に応じてルートの autofix.json)を作成します。

ルールスキーマ

各ルールは、以下のスキーマを持つJSON配列内に格納されます:

[
  {
    "Rule_number": 1,
    "Category": "CODE",
    "Instruction": "Reactコンポーネントにはデフォルトエクスポートを使用せず、常に名前付きエクスポートを使用してください。",
    "Why": "コードベースの一貫性を確保し、リファクタリングを容易にします。"
  }
]

許可されているカテゴリ

カテゴリ説明例
[STYLE]コードのフォーマット、命名規則、インポート順序、コメント「ヘルパー関数には常にキャメルケースを使用する」
[CODE]言語パターン、ライブラリの選択、型定義、エラーハンドリング「TypeScriptでanyを決して使用しない。型ガード付きのunknownを使用する」
[ARCH]ディレクトリ構造、モジュール境界、アーキテクチャ層「APIルートはsrc/api/ではなくsrc/server/routes/に配置する」
[TOOL]CLIコマンド、ビルドツール、パッケージマネージャー、テストフレームワーク「npmやyarnではなく常にpnpmを使用する」
[PROCESS]Gitワークフロー、コミットメッセージ、PR要件、テストゲート「コミットメッセージに絵文字を決して追加しない」
[DATA]データベーススキーマ、マイグレーション、キャッシュ戦略、状態の形状「テーブルには常にcreated_atとupdated_atタイムスタンプを含める」
[UX]UIの動作、コピーの慣習、アクセシビリティ標準「アイコンのみのボタンには常に明示的なaria-labelを提供する」
[OTHER]一般的なプロジェクトまたはドメイン固有の設定「公開APIエンドポイントは常にマークダウンテーブル形式で文書化する」

操作ワークフロー

[セッション開始 / タスク受信]
            │
            ▼
┌───────────────────────────────┐
│ 1. タスク前スキャン              │ ◄── autofix.json を読み込む
│    - すべてのルールをロード           │
│    - 競合を解決 (新しい>古い)
│    - アクティブな制約を構築 │
└───────────┬───────────────────┘
            │
            ▼
┌───────────────────────────────┐
│ 2. タスク実行             │
│    - 制約を適用        │
│    - コード/編集を実行     │
└───────────┬───────────────────┘
            │
            ├─────────────────────────────────────────┐
            │                                         │
     [修正なし]                         [トリガー検出]
            │                                         │
            ▼                                         ▼
┌───────────────────────────────┐       ┌───────────────────────────────┐
│ タスク完了                 │       │ 3. 自己修復とキャプチャ      │
│ 出力をユーザーに提供        │       │    - 命令的なルールを策定│
└───────────────────────────────┘       │    - autofix.json に追加   │
                                        │    - 学習したことを通知     │
                                        └─────────────┬─────────────────┘
                                                      │
                                                      ▼
                                        ┌───────────────────────────────┐
                                        │ 4. 再実行と修正       │
                                        │ 現在のタスク出力を修正       │
                                        └───────────────────────────────┘

詳細なステップバイステップの実行

1. タスク前スキャン (何かをする前に行う)

タスクの計画やファイルの変更を行う前に、以下を実行します:

  1. autofix.json を見つけてロードします。
  2. ルールをスキャンします:
    • 現在のプロンプトに関係するファイル、ツール、またはパターンに直接適用されるルールがないか確認します。
  3. 競合を解決します:
    • 2つのルールが相反する指示を与える場合、番号が大きい(新しい)ルールが優先されます。
  4. 制約をアクティブに保持します:
    • すべてのアクティブなルールをハード制約(プロンプトコントラクトの CONSTRAINTS と同等)として扱います。

2. ルールを追加するタイミング (トリガー条件)

以下のいずれかが発生した場合、直ちにルールのキャプチャをトリガーします:

  • ユーザーが明示的に出力を修正: 例: "いいえ、Xは使わないで、Yでやってください"、"ここではクラスコンポーネントを使いません"。
  • ユーザーがファイル、アプローチ、パターンを拒否: 例: "テストファイルをソースコードの隣に置かないでください"。
  • ユーザーが個人またはチームの好みを表明: 例: "コミットメッセージは常にConventional Commits形式にしてください"、"ドキュメントに絵文字は使わないでください"。
  • 間違った仮定が原因でバグが発生: エージェントがライブラリやファイルの場所を誤って想定し、それが原因で障害が発生しました。
  • ユーザーが /learn を実行するか、ルールを記憶するように要求する。

3. 新しいルールの追加

トリガーが発生した場合、以下のアトミックな更新を実行します:

  1. 既存の autofix.json 配列を読み取ります。
  2. 次の連続した Rule_number を決定します:
    • 既存の最大ルール番号が $N$ の場合、新しいルールは $N + 1$ です。
    • ファイルが空または新規の場合、1 から開始します。
  3. 新しいルールオブジェクトをフォーマットします:
    • Rule_number: 連続した整数。
    • Category: 標準カテゴリ(STYLE, CODE, ARCH, TOOL, PROCESS, DATA, UX, OTHER)のいずれか。
    • Instruction: 厳密な命令形式で記述:"絶対にXをする/しない - なぜならYだからです。"
    • Why: 簡単な理由(例: "ユーザーの好み", "コードベースのパターン", "フレームワークの制限")。
  4. ルールをJSON配列に追加し、2スペースインデントでフォーマットしてファイルを保存します。
  5. 既存のルールを決して削除しないでください。古いルールが新しいルールに取って代わられる場合、新しいルールの番号が大きくなるように記述して優先させます。
  6. ユーザーに簡単に通知します:

    "ルール #<N> ([CATEGORY]) を学習しました: <Instruction> — autofix.json に記録しました。"


4. ルールファイルの例 (autofix.json)

[
  {
    "Rule_number": 1,
    "Category": "PROCESS",
    "Instruction": "コミットメッセージに絵文字を決して追加しないでください - コミットタイトルはプレーンなConventional Commitsにしてください。",
    "Why": "ユーザーの好み"
  },
  {
    "Rule_number": 2,
    "Category": "ARCH",
    "Instruction": "APIルートハンドラは常に 'src/server/routes/' に配置し、'src/api/' には決して配置しないでください - 一貫したバックエンドアーキテクチャを維持します。",
    "Why": "既存のコードベースのパターン"
  },
  {
    "Rule_number": 3,
    "Category": "CODE",
    "Instruction": "すべての外部エントリポイントの入力検証には常にZodスキーマを使用してください - 型付けされていないランタイム入力を防ぎます。",
    "Why": "ランタイムエラーを防ぎ、型を強制します"
  }
]

ベストプラクティスとエッジケース

  • アトミックなJSON書き込み: 既存のJSON配列を常にパースし、新しいオブジェクトを追加し、有効なJSONを書き戻します。エスケープされていないテキストでファイルを破損しないでください。
  • 具体的かつ命令的に: 別のAIがあいまいさなく従えるルールを記述してください。"きれいなコードを書く" のような漠然としたアドバイスは避け、"コンポーネントの実装と一緒に、.types.ts ファイルに型を常にエクスポートする" のようにしてください。
  • 無限ループを避ける: ルールを記録する際に、ルールファイル自体に対して別の自己修復ループをトリガーしないでください。
  • ルールの上書き: ルール1が "Axiosを使用する" と言っていて、ユーザーが後で "すべてFetchに移行する" と指示した場合、理由を "ユーザーがネイティブFetchへの移行を要求(ルール1を上書き)" としてルール4 "Axiosの代わりに常にネイティブFetchを使用する" を追加します。

Individual skills in this repo

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

BIGboss248/nextjs-wordpress

Create, configure, manage, and validate Google Antigravity customizations including skills, rules, MCP servers, lifecycle hooks, plugins, and custom JSON configs. Use when adding new capabilities to Antigravity, configuring MCP servers, writing rules, creating skills, setting up hooks, or modernizing legacy workflows.

BIGboss248/nextjs-wordpress

Spawn multiple agents into a shared conversation where they debate, disagree, and converge on a solution via a shared chat.json file. Use for architecture decisions, code review debates, design trade-offs, or any problem that benefits from adversarial reasoning. Triggers on "chatroom", "agent debate", "have agents discuss", "agent chatroom", "debate this", or /agent-chatrooms. Also triggers on phrases like "have 3 agents argue about", "multi-agent discussion", or "let them debate".

BIGboss248/nextjs-wordpress

Always-active code intelligence, search, and navigation skill utilizing the codebase-memory MCP server. Enforces an index-first protocol (verifying and refreshing the knowledge graph via index_repository or index_status before searching, required because background auto_watch is disabled to eliminate editor stutter and system lag), followed by graph-first exploration (search_graph, trace_path, get_code_snippet, query_graph, get_architecture, detect_changes) instead of naive text grep or full-file reads. Always activate before searching the codebase, inspecting unknown architecture, finding symbols, or tracing callers/callees.

BIGboss248/nextjs-wordpress

>- Discover, interview, and craft comprehensive UX/UI design specifications (design-spec.md) and design tokens for web components. Triggers on "/component-design", "design component", "design section", "design UI", "wireframe component", or "create design spec".

BIGboss248/nextjs-wordpress

>- Configure and query WooCommerce APIs including WPGraphQL, WooGraphQL, and JWT auth for headless frontends. Use when connecting Next.js to WooCommerce or fetching store catalog data.

BIGboss248/nextjs-wordpress

Orchestrate parallel browser automation using multiple Chrome DevTools MCP instances. Use when a task requires doing the same browser action across many targets simultaneously (e.g., submitting contact forms, filling applications, scraping pages that need JS rendering). Spin up 1-5 parallel Chrome agents.

BIGboss248/nextjs-wordpress

Workflow for spawning an independent subagent to conduct unbiased code reviews and inject adversarial edge-case tests ([ComponentName].edge.test.tsx).

BIGboss248/nextjs-wordpress

>- Build Next.js App Router React components with Suspense skeletons, semantic OKLCH tokens, Jest + RTL unit tests, Playwright visual/hydration checks, and Tailwind logical styling. Triggers on "/nextjs-component-dev", "create component", "new component", "build component", or "develop component".

BIGboss248/nextjs-wordpress

>- Bootstrap, configure, and verify the complete Next.js App Router development environment, developer tooling, testing suites, MCP servers, Docker containerization, and CI/CD. Triggers on "/nextjs-dev-setup", "setup nextjs dev environment", "start a nextjs project", or "containerize nextjs app".

BIGboss248/nextjs-wordpress

>- Configure production health monitoring endpoints (/api/health), Docker Compose probes, and runtime metrics in Next.js App Router applications. Use when asked to "setup health check", "add health endpoint", "docker compose healthcheck nextjs", "configure health monitor", or "/nextjs-healthcheck".

BIGboss248/nextjs-wordpress

Bootstrap, configure, and verify next-intl App Router internationalization (proxy.ts/middleware.ts, next/root-params, [locale] layout, routing). Triggers on "/nextjs-i18n-setup", "setup i18n", "install next-intl", "configure next-intl", "add internationalization", "setup locale routing", "migrate to [locale]".

BIGboss248/nextjs-wordpress

Read/write translation dictionaries (messages/[locale].json), next-intl hooks (getTranslations/useTranslations), providers (Storybook/tests/subtrees), and BiDi styling. Triggers on "/nextjs-i18n-usage", "i18n dictionary", "use translations", "read dictionary", "i18n provider", "next-intl hooks", "storybook i18n", "test i18n", "add translation keys", "localize component", "create a component", "update a component".

BIGboss248/nextjs-wordpress

>- Configure, test, and verify OpenTelemetry (OTel) observability in Next.js App Router applications. Triggers on "/nextjs-otel", "setup otel", "configure opentelemetry", "test otel", or "verify opentelemetry".

BIGboss248/nextjs-wordpress

Step-by-step workflow for designing and building Next.js App Router pages (RSC page.tsx, loading skeleton, metadata, JSON-LD schema, and dynamic static params). Triggers on "/nextjs-page-dev", "create page", "new page", "develop page", "build route", or "implement page".

BIGboss248/nextjs-wordpress

>- Orchestrate end-to-end planning for Next.js App Router projects, generating canonical specifications, design systems, and a 7-phase modular implementation roadmap in docs/plan/. Triggers on "/nextjs-plan", "plan a nextjs project", "plan nextjs app", "create nextjs project plan", "outline nextjs architecture", or "generate plan".

BIGboss248/nextjs-wordpress

Workflow and engineering standards for crafting co-located Storybook CSF3 stories ([ComponentName].stories.tsx) with interactive controls, action spies, and 4 canonical theme variants.

BIGboss248/nextjs-wordpress

>- Build Next.js e-commerce frontends backed by WooCommerce APIs, handling ISR catalogs, cart sessions, and JWT authentication. Use when building or querying Next.js stores with WooCommerce.

BIGboss248/nextjs-wordpress

Setup, automate, and execute SEO audits, CI/CD pre-push/pre-deploy checks, and ranking optimizations using the seo CLI and MCP server.

BIGboss248/nextjs-wordpress

End-to-end repository onboarding and development environment setup skill. Scans repository structure, configures project metadata (docs/project.json), sets up the codebase-memory-mcp code intelligence knowledge graph server (in workspace mcp.json and globally for AGY only), configures git hooks with Husky and Commitlint, establishes multi-stage production Docker containerization, and automates credit-optimized Release Please CI/CD with multi-arch (AMD64 & ARM64) GHCR package deployment. Triggers on "/setup-repository", "setup repository", "setup repo", "initialize repository", "new repo setup", or when preparing any repository for development and AI agent workflows.

BIGboss248/nextjs-wordpress

AI screen scaffolding, layout generation, and variant exploration workflow powered by Google Stitch (StitchMCP). Consumes a component design specification (docs/design/components/[page name]/[component name]/design-spec.md), verifies and reuses the central Stitch project in docs/project.json (or creates/persists one if absent), seeds the project's design system into Stitch, synthesizes layout prompts to generate a screen and create one variant of the given design spec file, downloads and saves Stitch JPG screenshots and HTML code files directly into docs/design/components/[page name]/[component name]/stitch/ using binary-safe PowerShell Invoke-WebRequest, outputs image prompts to the user if visual assets are needed (without calling generate_image to conserve tokens), updates design-spec.md with Stitch layout benchmarks, and audits asset download integrity with an independent subagent. Triggers on "/stitch-design", "generate stitch screen", "create stitch variant", "scaffold screen with stitch", or "stitch...

関連スキル