Skip to content

feat: AGENTS.md に自動生成セクションを導入し repo-maintenance で更新可能に - #609

Merged
keito4 merged 2 commits into
mainfrom
feat/agents-md-auto-generation
Mar 21, 2026
Merged

feat: AGENTS.md に自動生成セクションを導入し repo-maintenance で更新可能に#609
keito4 merged 2 commits into
mainfrom
feat/agents-md-auto-generation

Conversation

@keito4

@keito4 keito4 commented Mar 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • AGENTS.md を静的セクション + AUTO-GENERATED マーカーで区切られた自動生成セクションに再構成
  • /repo-maintenance 実行時に自動生成セクション(Repository Overview, Project Structure, Available Commands, CI/CD Workflows, Quality Gates, Hooks)をリポジトリの現在の状態から再生成
  • repo-maintenance.md に Step 3.4.1 として更新ステップを追加

Changes

AGENTS.md

  • 静的セクション: Agent Guidelines, Development Standards, Git Conventions(手動管理)
  • 自動生成セクション: <!-- BEGIN AUTO-GENERATED --> マーカー内に6セクション
    • Repository Overview(tech stack, base image)
    • Project Structure(13 ディレクトリ)
    • Available Commands(29 コマンド)
    • CI/CD Workflows(13 ワークフロー)
    • Quality Gates(4 スクリプト)
    • Hooks(10 フック)

repo-maintenance.md

  • Step 3.4.1: AGENTS.md 自動生成セクション更新ステップ追加
  • Summary Report に AGENTS.md 項目追加
  • Related Commands テーブルに項目追加

Test plan

  • Prettier フォーマットチェック通過
  • ESLint 通過
  • 全テスト通過(101/101)
  • /repo-maintenance で AGENTS.md が正しく更新されることを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Replaced prior guidance with a new auto-generated repository overview and updated development standards for consistent wording and release-type formatting.
    • Added Git conventions: branch naming, Conventional Commits, PR limits and reviewer requirements.
  • Chores

    • Added repository maintenance steps to automatically regenerate designated sections of AGENTS.md, including progress summary lines and skip conditions when files/markers are absent.

- AGENTS.md を静的セクション(Agent Guidelines, Development Standards)と
  自動生成セクション(Repository Overview, Project Structure, Available Commands,
  CI/CD Workflows, Quality Gates, Hooks)に分離
- AUTO-GENERATED マーカーで囲まれた範囲を /repo-maintenance 実行時に再生成
- repo-maintenance.md に Step 3.4.1 として AGENTS.md 更新ステップを追加
- Summary Report と Related Commands テーブルにも項目追加

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 21, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds an AGENTS.md auto-generation step to repository maintenance docs and replaces AGENTS.md's former agent/config prose with a new auto-generated "Repository Overview" section; it also normalizes Development Standards wording and adds explicit Git conventions and PR guard rules.

Changes

Cohort / File(s) Summary
Auto-Generation Documentation
.claude/commands/repo-maintenance.md
Added step "3.4.1 AGENTS.md Auto-Generated Sections Update": procedure and collection logic to regenerate the <!-- BEGIN AUTO-GENERATED --> / <!-- END AUTO-GENERATED --> block from repository artifacts, plus progress-summary and related-commands status lines and skip conditions when AGENTS.md or markers are absent.
Auto-Generated Repository Overview
AGENTS.md
Replaced legacy "Claude Configuration"/"Development Quality Standards" content with an auto-generated "Repository Overview" block documenting tech stack, directory layout, Claude Code commands, CI/CD workflows, quality gates, and hook scripts. Normalized wording in Development Standards and replaced GitHub Actions Integration with a "Git Conventions" subsection specifying branch naming, Conventional Commits usage, and PR guard limits.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

released

Poem

🐰 A hop through files, I gather and hum,

Commands and workflows, all lined up to come.
AGENTS.md refreshed with neat, tidy cheer,
I nibble the markers and spring them clear —
Hooray for tidy docs, the repo's in gear!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing auto-generated sections in AGENTS.md and making them updatable via repo-maintenance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agents-md-auto-generation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keito4 keito4 self-assigned this Mar 21, 2026
@keito4

keito4 commented Mar 21, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

指摘事項

  1. .claude/commands の件数が誤りです。29 commands と記載されていますが、リポジトリ内の .claude/commands/*.mdREADME.md 除外)は 28 件です。ドキュメントの正確性に影響します。
    AGENTS.md:21-24

  2. CI/CD ワークフロー一覧が不完全です。coverage-report.ymlquality-gate-fallback.yml が存在するのに一覧に含まれていません。自動生成セクションの「現状反映」という前提と矛盾します。
    AGENTS.md:70-86

  3. Project Structure がトップレベルの tracked ディレクトリと一致していません(例: .codex/, .cursor/, .gemini/, .husky/, .vscode/, .zsh/, credentials/, vscode/ などが欠落)。自動生成ロジック(トップレベルディレクトリ収集)と出力が整合せず、ドキュメントの信頼性に影響します。
    AGENTS.md:21-35

判定
patch is incorrect — 自動生成セクションとして追加された内容が実リポジトリの現状と一致しておらず、ドキュメントの正確性を損なうため。信頼度 0.62


⚠️ 修正が必要です

上記のレビューで問題が指摘されています。修正してからマージしてください。


🤖 Generated by post_pr_ai_review.py hook

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb71aefa35

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread AGENTS.md Outdated
Comment on lines +84 to +86
| `dependabot-auto-merge.yml` | Auto-merge Dependabot PRs |
| `manual-release.yml` | Manual release trigger |
| `rebuild-docker-cache.yml` | Weekly Docker cache rebuild |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge List every workflow file in the auto-generated AGENTS table

This auto-generated workflow table stops at rebuild-docker-cache.yml, but in this same commit .github/workflows also contains coverage-report.yml and quality-gate-fallback.yml (checked via the commit tree). Because this section is intended to reflect repository state for AI agents, omitting existing workflows makes the generated context inaccurate and can cause maintenance/review commands to miss active CI paths.

Useful? React with 👍 / 👎.

Comment on lines +761 to +763
for d in */; do
[ "$d" = "node_modules/" ] || [ "$d" = "coverage/" ] || [ "$d" = ".git/" ] && continue
DIRS="$DIRS| \`${d%/}/\` | ... |\n"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include dot-directories when collecting top-level directories

The proposed generation logic uses for d in */, which does not match dot-prefixed directories in Bash unless dotglob is enabled. That means key folders like .claude/, .github/, and .devcontainer/ will be silently excluded from regenerated Project Structure, even though they are core sections in AGENTS metadata.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.claude/commands/repo-maintenance.md:
- Around line 689-695: The skip condition only checks for AGENTS.md existence
and the "BEGIN AUTO-GENERATED" marker but not the corresponding "END
AUTO-GENERATED" marker, which can cause silent failures during the TAIL
extraction; update the shell conditional that guards the replacement logic to
also verify the presence of "END AUTO-GENERATED" in AGENTS.md (i.e., add a grep
check for "END AUTO-GENERATED" to the OR list) so the script explicitly
skips/aborts if either marker is missing and avoids truncating AGENTS.md.

In `@AGENTS.md`:
- Around line 140-142: The documented PR guard in AGENTS.md lists strict
requirements (PR guard: Diff <= 400 lines, <= 25 files, linked issue required,
1+ reviewer) that the repository automation does not enforce; either implement
enforcement or change the doc to a guideline. To fix: either (A) add CI/husky
checks that enforce the exact rules referenced (implement size/file-count checks
and require linked issue/reviewer in your existing CI or husky scripts
referenced in the repo), or (B) update AGENTS.md to reword the “PR guard”
section to clearly state these are recommended guidelines and reflect the
current behavior of the CI/husky snippets, ensuring the text mentions the
thresholds `<= 400 lines`, `<= 25 files`, “linked issue”, and “1+ reviewer” so
readers know what was intended. Ensure the change touches the PR guard wording
in AGENTS.md and/or the CI/husky configuration that performs checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4f1fb4bd-c0be-4cbd-9122-790eefb692b3

📥 Commits

Reviewing files that changed from the base of the PR and between b97befa and eb71aef.

📒 Files selected for processing (2)
  • .claude/commands/repo-maintenance.md
  • AGENTS.md

Comment on lines +689 to +695
**スキップ条件:**

```bash
# AGENTS.md が存在しない、またはマーカーがない場合はスキップ
if [ ! -f "AGENTS.md" ] || ! grep -q "BEGIN AUTO-GENERATED" AGENTS.md; then
echo "⏭️ スキップ(AGENTS.md 未対応)"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify this section checks both BEGIN and END markers before replacement.
rg -n -C2 'BEGIN AUTO-GENERATED|END AUTO-GENERATED|AGENTS\.md 未対応' .claude/commands/repo-maintenance.md

Repository: keito4/config

Length of output: 1036


Check for both BEGIN and END markers before executing replacement logic.

Line 693 validates only BEGIN AUTO-GENERATED, but the replacement at lines 778–779 depends on both markers. A missing or corrupted END AUTO-GENERATED will cause the TAIL extraction to fail silently, resulting in truncated or corrupted AGENTS.md. Add an explicit check for the END marker in the skip condition.

Suggested fix
-# AGENTS.md が存在しない、またはマーカーがない場合はスキップ
-if [ ! -f "AGENTS.md" ] || ! grep -q "BEGIN AUTO-GENERATED" AGENTS.md; then
+# AGENTS.md が存在しない、または BEGIN/END マーカーが揃っていない場合はスキップ
+if [ ! -f "AGENTS.md" ] \
+  || ! grep -q "BEGIN AUTO-GENERATED" AGENTS.md \
+  || ! grep -q "END AUTO-GENERATED" AGENTS.md; then
   echo "⏭️ スキップ(AGENTS.md 未対応)"
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
**スキップ条件:**
```bash
# AGENTS.md が存在しない、またはマーカーがない場合はスキップ
if [ ! -f "AGENTS.md" ] || ! grep -q "BEGIN AUTO-GENERATED" AGENTS.md; then
echo "⏭️ スキップ(AGENTS.md 未対応)"
fi
**スキップ条件:**
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/commands/repo-maintenance.md around lines 689 - 695, The skip
condition only checks for AGENTS.md existence and the "BEGIN AUTO-GENERATED"
marker but not the corresponding "END AUTO-GENERATED" marker, which can cause
silent failures during the TAIL extraction; update the shell conditional that
guards the replacement logic to also verify the presence of "END AUTO-GENERATED"
in AGENTS.md (i.e., add a grep check for "END AUTO-GENERATED" to the OR list) so
the script explicitly skips/aborts if either marker is missing and avoids
truncating AGENTS.md.

Comment thread AGENTS.md
Comment on lines +140 to +142
- Branch naming: `feat|fix|chore/<issue#>-slug`
- Commit format: Conventional Commits
- PR guard: Diff <= 400 lines, <= 25 files, linked issue required, 1+ reviewer

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Documented PR guard is stricter than what is actually enforced.

Line 142 describes hard PR guard rules (<=400 lines, <=25 files, linked issue, reviewer), but current automation (CI/husky snippets) only warns on much larger PR sizes and does not enforce linked-issue/reviewer requirements. Please either implement these checks or reword this as a guideline to avoid false assurance.

Suggested wording update
-- PR guard: Diff <= 400 lines, <= 25 files, linked issue required, 1+ reviewer
+- PR guideline: Keep diffs <= 400 lines and <= 25 files when possible; linked issue and at least 1 reviewer are recommended. (Current CI posts size warnings; hard enforcement may vary by repository settings.)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Branch naming: `feat|fix|chore/<issue#>-slug`
- Commit format: Conventional Commits
- PR guard: Diff <= 400 lines, <= 25 files, linked issue required, 1+ reviewer
- Branch naming: `feat|fix|chore/<issue#>-slug`
- Commit format: Conventional Commits
- PR guideline: Keep diffs <= 400 lines and <= 25 files when possible; linked issue and at least 1 reviewer are recommended. (Current CI posts size warnings; hard enforcement may vary by repository settings.)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` around lines 140 - 142, The documented PR guard in AGENTS.md lists
strict requirements (PR guard: Diff <= 400 lines, <= 25 files, linked issue
required, 1+ reviewer) that the repository automation does not enforce; either
implement enforcement or change the doc to a guideline. To fix: either (A) add
CI/husky checks that enforce the exact rules referenced (implement
size/file-count checks and require linked issue/reviewer in your existing CI or
husky scripts referenced in the repo), or (B) update AGENTS.md to reword the “PR
guard” section to clearly state these are recommended guidelines and reflect the
current behavior of the CI/husky snippets, ensuring the text mentions the
thresholds `<= 400 lines`, `<= 25 files`, “linked issue”, and “1+ reviewer” so
readers know what was intended. Ensure the change touches the PR guard wording
in AGENTS.md and/or the CI/husky configuration that performs checks.

@claude

claude Bot commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

コードレビュー

概要

AGENTS.md を静的セクションと自動生成セクションに分離し、/repo-maintenance での自動更新を可能にするアプローチは良い設計です。AI エージェントが常に正確なリポジトリコンテキストを参照できるようになります。


バグ: ディレクトリ除外ロジックの shell 演算子優先順位

repo-maintenance.md の参考ロジック (Step 3.4.1)

for d in */; do
  [ "$d" = "node_modules/" ] || [ "$d" = "coverage/" ] || [ "$d" = ".git/" ] && continue

bash では &&|| より優先度が高いため、上記は以下と等価になります:

[ node_modules/ ] || [ coverage/ ] || ([ .git/ ] && continue)

node_modules/coverage/ にマッチした場合、OR が短絡評価されて continue が実行されません。.git/ のみが正しく除外されます。

修正案:

for d in */; do
  case "$d" in
    node_modules/|coverage/|.git/) continue ;;
  esac

注記: このロジックは「参考ロジック」であり Claude Code が解釈して実行するとの記載がありますが、参考コードの誤りはエージェントを誤誘導する可能性があるため修正推奨です。


注意: sed による frontmatter パース

frontmatter の description 取得に sed -n '/^---$/,/^---$/{...}' パターンを使用していますが、開始・終了パターンが同一の場合、一部の sed 実装では2行目の --- が次の範囲の開始として扱われ、意図しない挙動になることがあります。awk を使った代替案の検討を推奨します。


テスト計画の未完了項目

PR の Test plan に未チェック項目があります:

  • /repo-maintenance で AGENTS.md が正しく更新されることを確認

実際に /repo-maintenance を実行して自動生成セクションが正しく更新されることを確認してからマージすることを推奨します。


Unicode アロー文字の変更

CLAUDE.md では (Unicode)が使用されています。AGENTS.md が CLAUDE.md のシンボリックリンク元であることを考えると、統一した方が自然です(機能的な問題はありません)。


良い点

  • 明確なマーカー設計: <!-- BEGIN AUTO-GENERATED --> / <!-- END AUTO-GENERATED --> で静的・動的セクションを明確に分離
  • 自動生成ソースの文書化: 各セクションのデータソース(package.json, .claude/commands/*.md 等)が明示されている
  • Summary Report への統合: 既存の出力フォーマットに自然に統合されている
  • 静的セクションの保護: Agent Guidelines と Development Standards は手動管理として明確に分離
  • 後方互換性: マーカー未対応のファイルはスキップする条件分岐あり

総評

コンセプトは良く、構造も整理されています。主な愗念は参考ロジックのシェルスクリプトのバグと、エンドツーエンドテストの未確認です。バグ修正と動作確認を行ってからマージすることを推奨します。

Generated with Claude Code

- コマンド数を 29 -> 28 に修正
- 欠落ワークフロー追加: coverage-report.yml, quality-gate-fallback.yml
- Project Structure に欠落ディレクトリ追加: .agents/, .codex/, .cursor/,
  .gemini/, .husky/, .vscode/, credentials/
- シェルスクリプトの ||/&& 演算子優先順位バグを case 文で修正
- bun ロックファイル検出の ||/&& バグをグループ化で修正
- sed による frontmatter パースを awk に置き換え

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@keito4
keito4 merged commit ad64127 into main Mar 21, 2026
3 of 4 checks passed
@keito4
keito4 deleted the feat/agents-md-auto-generation branch March 21, 2026 09:39
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.102.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant