Skip to content

feat: AGENTS.md 自動生成スクリプトを追加し repo-maintenance に組み込み - #615

Merged
keito4 merged 3 commits into
mainfrom
feat/agents-md-update-script
Mar 22, 2026
Merged

feat: AGENTS.md 自動生成スクリプトを追加し repo-maintenance に組み込み#615
keito4 merged 3 commits into
mainfrom
feat/agents-md-update-script

Conversation

@keito4

@keito4 keito4 commented Mar 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • script/update-agents-md.sh を追加: AGENTS.md の自動生成セクションをリポジトリの現在の状態から再生成するスクリプト
  • /repo-maintenance の Step 3.4.1 を「参考ロジック」からスクリプト呼び出しに変更

背景

これまで AGENTS.md の自動生成セクション更新は、repo-maintenance 実行時に Claude が手動で判断・編集していました。そのため、ディレクトリ追加やワークフロー変更が反映漏れになる問題がありました。

script/update-agents-md.sh の仕様

機能 説明
自動収集 Tech stack, ディレクトリ, コマンド, ワークフロー, Quality Gates, Hooks
--check モード 差分チェックのみ(差分あれば exit 1)
Prettier 連携 生成後に自動フォーマット、冪等性を保証
Nix 対応 nix/flake.nix の存在を検出して macOS Environment を追記

repo-maintenance での使い方

MODE 動作
full bash script/update-agents-md.sh で更新を適用
quick / check-only bash script/update-agents-md.sh --check で差分を報告のみ

Test plan

  • bash script/update-agents-md.sh → 正常に再生成
  • bash script/update-agents-md.sh --check → exit 0(冪等性確認)
  • 全テスト通過 (95 tests)
  • Prettier フォーマット通過

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automated documentation generation script for maintaining project metadata and configuration details.
  • Documentation

    • Expanded project documentation with environment specifications, available commands, CI/CD workflows, quality gates, hooks, and development standards.
  • Tests

    • Updated integration tests to support flexible GitHub Actions versioning schemes.

AGENTS.md の自動生成セクション更新を実行可能なスクリプトとして実装し、
/repo-maintenance から確実に実行される仕組みにする。

追加:
- script/update-agents-md.sh: リポジトリ状態から AGENTS.md を自動再生成
  - --check モード: 差分チェックのみ(exit 1 で差分あり)
  - Prettier 適用後の冪等性を保証
  - Tech stack, ディレクトリ, コマンド, ワークフロー, Quality Gates, Hooks を自動収集

変更:
- .claude/commands/repo-maintenance.md: Step 3.4.1 を参考ロジックから
  スクリプト呼び出しに変更し、MODE ごとの動作を明記

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

coderabbitai Bot commented Mar 22, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces automated AGENTS.md regeneration infrastructure via a new Bash script (script/update-agents-md.sh) that inspects repository state and updates auto-generated sections. Documentation is updated to describe the process, and integration tests are relaxed to accept flexible GitHub Actions version pinning without specific version constraints.

Changes

Cohort / File(s) Summary
Documentation & Auto-Generation Configuration
.claude/commands/repo-maintenance.md, AGENTS.md
Updated documentation to describe script/update-agents-md.sh execution, expanded repository overview with additional directories, revised command/workflow/hook descriptions, and added Development Standards section with semantic-release rules.
Automation Script
script/update-agents-md.sh
New 302-line Bash script that auto-generates AGENTS.md's auto-generated block by inspecting Node.js version, package manager, Nix environment, directories, Claude commands, GitHub workflows, quality gates, and hooks. Supports --check mode and Prettier formatting for idempotency.
Integration Tests
test/integration/coverage-report-workflow.bats, test/integration/workflows.bats
Updated test assertions to match GitHub Actions with flexible @ suffix matching instead of specific version patterns (e.g., @v6@), allowing SHA-pinned or tag-pinned references.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

released

Poem

🐰✨ A script to tend the garden fair,
Where AGENTS bloom with utmost care,
Automation weaves through every seam,
Idempotent dreams, a developer's dream!

🚥 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 summarizes the main change: adding an AGENTS.md auto-generation script and integrating it into repo-maintenance documentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

Important

Merge conflicts detected (Beta)

  • Resolve merge conflict in branch feat/agents-md-update-script
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agents-md-update-script

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 commented Mar 22, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

以下は、git merge-base で特定した差分(467665177576b178be8f6b3cd34c397125bed738..HEAD)に対するレビューです。

  1. Markdown テーブルが壊れる(コマンド内の | 未エスケープ)
    該当: script/update-agents-md.sh:120-131
    影響: collect_quality_gatespackage.json の script 値をそのままテーブルに挿入しており、shellcheck のように | を含むコマンドで列が増えてテーブルが崩れます。実際に AGENTS.md:124-130 で列数が破綻しています。
    対応案: val|\| に置換してから埋め込む(例: val=${val//|/\\|})。

  2. リポジトリの運用ルール違反(/tmp の使用)
    該当: script/update-agents-md.sh:277-283
    影響: ルール上、臨時ファイルは .context/ 配下に置く必要がありますが、mktemp /tmp/... を使用しています。他エージェントから参照できず、運用ルール違反になります。
    対応案: .context/ を作成してそこに一時ファイルを作る(例: mkdir -p .context + mktemp .context/agents-md-check-XXXXX.md)。

判定: patch is incorrect
理由: 生成物の Markdown が壊れる問題と運用ルール違反が導入されているため。
信頼度: 0.68


⚠️ 修正が必要です

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


🤖 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: c1b2dff28a

ℹ️ 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".

local val
val=$(jq -r --arg k "$key" '.scripts[$k] // empty' package.json 2>/dev/null)
if [[ -n "$val" ]]; then
gates+="| \`$key\` | \`$val\` | ${purposes[$i]} |"$'\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 Escape table delimiters in generated script commands

collect_quality_gates injects raw npm script text into a Markdown table cell, so commands containing | (like the current shellcheck pipeline) are split into extra columns and corrupt the table structure in AGENTS.md. This makes the generated section hard to read and unreliable for any tooling that expects a 3-column table; escape | (for example to \|) before writing the cell content.

Useful? React with 👍 / 👎.


if [[ "$CHECK_ONLY" == "true" ]]; then
# Write to temp file and format for accurate comparison
TMPFILE=$(mktemp /tmp/agents-md-check-XXXXX.md)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Store check-mode temp artifacts under .context

In --check mode the script writes its intermediate file to /tmp, which conflicts with the repository rule in /workspace/config/AGENTS.md ("Temporary Files") requiring temp/context artifacts to live under .context/ so other agents can inspect and clean them. This breaks the documented multi-agent workflow and should be switched to a .context-scoped temp path.

Useful? React with 👍 / 👎.

| Script | Command | Purpose |
| --- | --- | --- |
${QUALITY_GATES}
Additional test commands: \`test:integration\` (BATS), \`test:coverage\` (Jest + coverage), \`test:all\` (unit + integration)

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 Emit extra test commands from detected scripts

The script computes EXTRA_TESTS dynamically but then ignores it and always prints a fixed Additional test commands line, so repositories missing one or more of these scripts will get inaccurate autogenerated documentation. This is a functional mismatch with the detection logic above and should render the section from EXTRA_TESTS instead of a hard-coded string.

Useful? React with 👍 / 👎.

@keito4 keito4 self-assigned this Mar 22, 2026
@claude

claude Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

test

@claude

claude Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Test

@claude

claude Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

コードレビュー
バグ・ロジック問題

@claude

claude Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

コードレビュー

バグ問題

@claude

claude Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

コードレビュー

PR の方針(手動編集 → スクリプト自動生成)は良いアプローチです。以下にフィードバックをまとめます。


バグ・ロジック問題

1. EXTRA_LINE が dead code(script/update-agents-md.sh)

collect_extra_tests()EXTRA_LINE の構築ロジックが存在しますが、AUTO_CONTENT では一切使用されておらず、ハードコードされた文字列が使われています(355行付近)。

加えて echo EXTRA_TESTS | while ... はパイプでサブシェルが生成されるため、ループ内の EXTRA_LINE+= は外部に伝播しません(bash のパイプサブシェル問題)。

提案: collect_extra_tests()EXTRA_LINE 関連コードを削除するか、AUTO_CONTENT のハードコード行を実際の変数参照に置き換えて動作させる。後者の場合、パイプをプロセス置換形式に変更が必要。


ドキュメント品質の後退

2. CI/CD Workflows の説明が大幅に短縮

ワークフロー name: フィールドを自動取得しているため、以前の詳細な説明が失われています。例として ci.yml が「Code quality validation (lint, format, test, build). Required status check: Quality Gate」から「CI」に短縮されています。

提案: YAML の name: を詳細化するか、スクリプトに overrides map を持たせる。

3. Available Commands の説明が (no description) だらけ

frontmatter に description: がないコマンドが多く、旧来の手動記述の説明が失われました。各コマンドの frontmatter に description: を追加することを推奨します。


/tmp/ の使用(CLAUDE.md ルール)

--check モードで /tmp/ を使用しています。CLAUDE.md では一時ファイルは .context/ 配下を使うよう規定されています。


良い点

  • set -euo pipefail による安全なスクリプト設計
  • trap による temp ファイルのクリーンアップ
  • --check モードで冪等性確認が可能
  • Prettier との連携で出力の一貫性を保証
  • マーカーベース(BEGIN/END AUTO-GENERATED)の置換で手動編集セクションを保護

まとめ

最重要修正は EXTRA_LINE の dead code(削除か機能させるかどちらか)です。CI/CD 説明の品質後退はトレードオフですが name: フィールドの改善または overrides map で解決できます。

Generated with Claude Code

Actions を SHA 固定したことにより、`@v6` や `@v7` のタグ参照を
期待していた BATS テストが失敗していた。
`@` の後にタグまたは SHA が続くパターンに変更。

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

@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: 4

🧹 Nitpick comments (2)
test/integration/workflows.bats (1)

131-140: Consider strengthening global pinning check to also catch @latest.

This global test provides excellent baseline security for all workflows. The relaxed individual assertions rely on this check to catch floating refs. Adding @latest would close a potential gap:

🛡️ Suggested enhancement
 `@test` "all workflows pin action versions" {
   local workflows_dir="${REPO_ROOT}/.github/workflows"

   for workflow in "$workflows_dir"/*.yml; do
     # Check that actions use `@vX` or `@commit_hash`
     # Should not use `@main` or `@master`
     ! grep -q "uses:.*@main" "$workflow"
     ! grep -q "uses:.*@master" "$workflow"
+    ! grep -q "uses:.*@latest" "$workflow"
   done
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/integration/workflows.bats` around lines 131 - 140, The test "all
workflows pin action versions" currently checks for floating refs `@main` and
`@master` but misses `@latest`; update the test loop (inside the for workflow in
"$workflows_dir"/*.yml) to also assert that no workflow uses `@latest` by adding a
check like: ! grep -q "uses:.*@latest" "$workflow" so workflows cannot reference
`@latest` in action pins.
test/integration/coverage-report-workflow.bats (1)

44-44: Relaxed patterns accommodate SHA pinning but miss @latest floating ref.

The change from @vN to @ correctly accommodates SHA-pinned actions (which are more secure than version tags). The existing negative assertions on lines 57-58 catch @main and @master.

However, @latest is another common floating ref that would pass these relaxed patterns. Consider adding it to the negative assertions in the existing test at lines 56-59:

🛡️ Suggested enhancement to catch `@latest`
 `@test` "coverage-report.yml uses pinned action versions" {
   ! grep -q "uses:.*@main" "$WORKFLOW"
   ! grep -q "uses:.*@master" "$WORKFLOW"
+  ! grep -q "uses:.*@latest" "$WORKFLOW"
 }

Also applies to: 53-53, 62-62, 74-75, 80-80

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/integration/coverage-report-workflow.bats` at line 44, Update the
integration test assertions to also reject the floating ref "@latest" where the
test currently only rejects "@main" and "@master"; specifically, modify the
negative grep checks that inspect "$WORKFLOW" (the grep for
"madrapps/jacoco-report@" and the related negative assertions around lines
56-59, and the other similar checks at 53, 62, 74-75, 80) to include "@latest"
alongside "@main" and "@master" so the regex/patterns disallow "@latest" as well
as other floating refs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@AGENTS.md`:
- Around line 124-130: The Markdown table is broken because unescaped pipe
characters from script values are inserted into the table cell; update the
collect_quality_gates() function in script/update-agents-md.sh to sanitize $val
before writing it into AGENTS.md by either escaping all '|' characters (replace
'|' with '\|') or enclosing the command string in a code span/backticks so pipes
are treated as literal content; ensure the transformed value is what gets
written to the table generation logic (where $val is used) so the rendered
Markdown table remains intact.

In `@script/update-agents-md.sh`:
- Around line 119-134: The collect_quality_gates function can corrupt the
Markdown table when package.json script values contain pipe characters; modify
collect_quality_gates so that after retrieving val (from jq) you escape pipe
characters (e.g., replace '|' with '\|' or '&#124;') into a new variable (name
it escaped_val) and then append escaped_val (not val) into gates; update the
gates assembly line that currently references val to use escaped_val, keeping
the backticks and preserving purposes and existing formatting.
- Around line 277-293: Replace the use of OS temp dir with a repo-scoped
.context temp file: ensure .context exists (mkdir -p .context) and create
TMPFILE using mktemp with a .context prefix (e.g. mktemp
.context/agents-md-check-XXXXX.md), keep the trap to rm -f "$TMPFILE", write
NEW_CONTENT to "$TMPFILE", run npx prettier on "$TMPFILE" as before, and compare
TMPFILE with AGENTS_MD; update references to TMPFILE, CHECK_ONLY, NEW_CONTENT
and AGENTS_MD accordingly so all temporary artifacts live under .context/.
- Around line 194-208: The EXTRA_LINE building loop currently runs in a subshell
(echo "$EXTRA_TESTS" | while ...) so updates to EXTRA_LINE are lost; replace the
pipeline with a non-subshell approach such as using a here-string or process
substitution (e.g., while IFS= read -r t; do ... done <<< "$EXTRA_TESTS" or done
< <(printf '%s\n' "$EXTRA_TESTS")) so mutations to EXTRA_LINE persist, ensure
you reference collect_extra_tests/EXTRA_TESTS/EXTRA_LINE exactly and remove or
update the hardcoded "extra tests" output later to use the dynamically built
EXTRA_LINE (or delete this block if you intentionally want the hardcoded text).

---

Nitpick comments:
In `@test/integration/coverage-report-workflow.bats`:
- Line 44: Update the integration test assertions to also reject the floating
ref "@latest" where the test currently only rejects "@main" and "@master";
specifically, modify the negative grep checks that inspect "$WORKFLOW" (the grep
for "madrapps/jacoco-report@" and the related negative assertions around lines
56-59, and the other similar checks at 53, 62, 74-75, 80) to include "@latest"
alongside "@main" and "@master" so the regex/patterns disallow "@latest" as well
as other floating refs.

In `@test/integration/workflows.bats`:
- Around line 131-140: The test "all workflows pin action versions" currently
checks for floating refs `@main` and `@master` but misses `@latest`; update the test
loop (inside the for workflow in "$workflows_dir"/*.yml) to also assert that no
workflow uses `@latest` by adding a check like: ! grep -q "uses:.*@latest"
"$workflow" so workflows cannot reference `@latest` in action pins.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9033cad3-9018-448c-af6b-2664856c9fa7

📥 Commits

Reviewing files that changed from the base of the PR and between 4676651 and 64b069b.

📒 Files selected for processing (5)
  • .claude/commands/repo-maintenance.md
  • AGENTS.md
  • script/update-agents-md.sh
  • test/integration/coverage-report-workflow.bats
  • test/integration/workflows.bats

Comment thread AGENTS.md
Comment on lines +124 to 130
| Script | Command | Purpose |
| -------------- | ---------------------------------- | ------------------------------------ | ----------------------- | ----------------------- |
| `format:check` | `prettier --check .` | Code formatting validation |
| `lint` | `eslint . --ext .js` | Code quality validation |
| `test` | `jest --runInBand` | Unit test execution |
| `shellcheck` | `find script -name '\*.sh' -type f | grep -vFf script/.shellcheck-exclude | xargs -r shellcheck -x` | Shell script validation |

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 | 🔴 Critical

Markdown table is malformed due to unescaped pipe characters.

The shellcheck command value contains literal | characters that break the table structure:

  • Line 125 defines a 3-column table separator
  • Line 129 has unescaped pipes in the command: find ... | grep ... | xargs ...

This causes the Markdown renderer to interpret pipes as column delimiters, breaking the table layout.

The root cause is in script/update-agents-md.sh at collect_quality_gates() (lines 120-134) where $val from package.json scripts is inserted directly without escaping.

🐛 Fix in script/update-agents-md.sh
 for i in "${!scripts[@]}"; do
   local key="${scripts[$i]}"
   local val
   val=$(jq -r --arg k "$key" '.scripts[$k] // empty' package.json 2>/dev/null)
   if [[ -n "$val" ]]; then
+    # Escape pipe characters for Markdown table
+    val="${val//|/\\|}"
     gates+="| \`$key\` | \`$val\` | ${purposes[$i]} |"$'\n'
   fi
 done
📝 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
| Script | Command | Purpose |
| -------------- | ---------------------------------- | ------------------------------------ | ----------------------- | ----------------------- |
| `format:check` | `prettier --check .` | Code formatting validation |
| `lint` | `eslint . --ext .js` | Code quality validation |
| `test` | `jest --runInBand` | Unit test execution |
| `shellcheck` | `find script -name '\*.sh' -type f | grep -vFf script/.shellcheck-exclude | xargs -r shellcheck -x` | Shell script validation |
| Script | Command | Purpose |
| -------------- | ---------------------------------- | ------------------------------------ |
| `format:check` | `prettier --check .` | Code formatting validation |
| `lint` | `eslint . --ext .js` | Code quality validation |
| `test` | `jest --runInBand` | Unit test execution |
| `shellcheck` | `find script -name '\*.sh' -type f \| grep -vFf script/.shellcheck-exclude \| xargs -r shellcheck -x` | Shell script validation |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@AGENTS.md` around lines 124 - 130, The Markdown table is broken because
unescaped pipe characters from script values are inserted into the table cell;
update the collect_quality_gates() function in script/update-agents-md.sh to
sanitize $val before writing it into AGENTS.md by either escaping all '|'
characters (replace '|' with '\|') or enclosing the command string in a code
span/backticks so pipes are treated as literal content; ensure the transformed
value is what gets written to the table generation logic (where $val is used) so
the rendered Markdown table remains intact.

Comment on lines +119 to +134
# --- 5. Collect quality gates ---
collect_quality_gates() {
local gates=""
local scripts=("format:check" "lint" "test" "shellcheck" "typecheck" "type-check" "tsc")
local purposes=("Code formatting validation" "Code quality validation" "Unit test execution" "Shell script validation" "Type checking" "Type checking" "Type checking")

for i in "${!scripts[@]}"; do
local key="${scripts[$i]}"
local val
val=$(jq -r --arg k "$key" '.scripts[$k] // empty' package.json 2>/dev/null)
if [[ -n "$val" ]]; then
gates+="| \`$key\` | \`$val\` | ${purposes[$i]} |"$'\n'
fi
done
echo -n "$gates"
}

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 | 🔴 Critical

Escape pipe characters in Quality Gates values to prevent Markdown table corruption.

Script values from package.json may contain | (pipe) characters (e.g., find ... | grep ... | xargs). When inserted directly into Markdown tables, these break the column structure.

🐛 Proposed fix
 for i in "${!scripts[@]}"; do
   local key="${scripts[$i]}"
   local val
   val=$(jq -r --arg k "$key" '.scripts[$k] // empty' package.json 2>/dev/null)
   if [[ -n "$val" ]]; then
+    # Escape pipe characters for Markdown table compatibility
+    val="${val//|/\\|}"
     gates+="| \`$key\` | \`$val\` | ${purposes[$i]} |"$'\n'
   fi
 done
📝 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
# --- 5. Collect quality gates ---
collect_quality_gates() {
local gates=""
local scripts=("format:check" "lint" "test" "shellcheck" "typecheck" "type-check" "tsc")
local purposes=("Code formatting validation" "Code quality validation" "Unit test execution" "Shell script validation" "Type checking" "Type checking" "Type checking")
for i in "${!scripts[@]}"; do
local key="${scripts[$i]}"
local val
val=$(jq -r --arg k "$key" '.scripts[$k] // empty' package.json 2>/dev/null)
if [[ -n "$val" ]]; then
gates+="| \`$key\` | \`$val\` | ${purposes[$i]} |"$'\n'
fi
done
echo -n "$gates"
}
# --- 5. Collect quality gates ---
collect_quality_gates() {
local gates=""
local scripts=("format:check" "lint" "test" "shellcheck" "typecheck" "type-check" "tsc")
local purposes=("Code formatting validation" "Code quality validation" "Unit test execution" "Shell script validation" "Type checking" "Type checking" "Type checking")
for i in "${!scripts[@]}"; do
local key="${scripts[$i]}"
local val
val=$(jq -r --arg k "$key" '.scripts[$k] // empty' package.json 2>/dev/null)
if [[ -n "$val" ]]; then
# Escape pipe characters for Markdown table compatibility
val="${val//|/\\|}"
gates+="| \`$key\` | \`$val\` | ${purposes[$i]} |"$'\n'
fi
done
echo -n "$gates"
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@script/update-agents-md.sh` around lines 119 - 134, The collect_quality_gates
function can corrupt the Markdown table when package.json script values contain
pipe characters; modify collect_quality_gates so that after retrieving val (from
jq) you escape pipe characters (e.g., replace '|' with '\|' or '&#124;') into a
new variable (name it escaped_val) and then append escaped_val (not val) into
gates; update the gates assembly line that currently references val to use
escaped_val, keeping the backticks and preserving purposes and existing
formatting.

Comment on lines +194 to +208
# Extra test info
EXTRA_TESTS=$(collect_extra_tests)
EXTRA_LINE=""
if [[ -n "$EXTRA_TESTS" ]]; then
EXTRA_LINE="Additional test commands:"
echo "$EXTRA_TESTS" | while IFS= read -r t; do
[[ -z "$t" ]] && continue
case "$t" in
test:integration) EXTRA_LINE+=" \`$t\` (BATS)," ;;
test:coverage) EXTRA_LINE+=" \`$t\` (Jest + coverage)," ;;
test:all) EXTRA_LINE+=" \`$t\` (unit + integration)," ;;
*) EXTRA_LINE+=" \`$t\`," ;;
esac
done
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 | 🟡 Minor

Subshell variable scope issue makes EXTRA_LINE building ineffective.

The pipeline echo "$EXTRA_TESTS" | while read ... runs the while loop in a subshell. Modifications to EXTRA_LINE inside the loop are lost when the subshell exits.

Additionally, line 251 hardcodes the extra tests line rather than using the dynamically built EXTRA_LINE, making this code block effectively dead code.

🔧 Option 1: Use process substitution to avoid subshell
-EXTRA_LINE=""
-if [[ -n "$EXTRA_TESTS" ]]; then
-  EXTRA_LINE="Additional test commands:"
-  echo "$EXTRA_TESTS" | while IFS= read -r t; do
+EXTRA_LINE="Additional test commands:"
+if [[ -n "$EXTRA_TESTS" ]]; then
+  while IFS= read -r t; do
     [[ -z "$t" ]] && continue
     case "$t" in
       test:integration) EXTRA_LINE+=" \`$t\` (BATS)," ;;
       test:coverage)    EXTRA_LINE+=" \`$t\` (Jest + coverage)," ;;
       test:all)         EXTRA_LINE+=" \`$t\` (unit + integration)," ;;
       *)                EXTRA_LINE+=" \`$t\`," ;;
     esac
-  done
+  done <<< "$EXTRA_TESTS"
+  # Remove trailing comma
+  EXTRA_LINE="${EXTRA_LINE%,}"
 fi
🗑️ Option 2: Remove dead code and keep the hardcoded line

If the hardcoded output at line 251 is intentional, remove lines 194-208 entirely as they serve no purpose.

📝 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
# Extra test info
EXTRA_TESTS=$(collect_extra_tests)
EXTRA_LINE=""
if [[ -n "$EXTRA_TESTS" ]]; then
EXTRA_LINE="Additional test commands:"
echo "$EXTRA_TESTS" | while IFS= read -r t; do
[[ -z "$t" ]] && continue
case "$t" in
test:integration) EXTRA_LINE+=" \`$t\` (BATS)," ;;
test:coverage) EXTRA_LINE+=" \`$t\` (Jest + coverage)," ;;
test:all) EXTRA_LINE+=" \`$t\` (unit + integration)," ;;
*) EXTRA_LINE+=" \`$t\`," ;;
esac
done
fi
# Extra test info
EXTRA_TESTS=$(collect_extra_tests)
EXTRA_LINE="Additional test commands:"
if [[ -n "$EXTRA_TESTS" ]]; then
while IFS= read -r t; do
[[ -z "$t" ]] && continue
case "$t" in
test:integration) EXTRA_LINE+=" \`$t\` (BATS)," ;;
test:coverage) EXTRA_LINE+=" \`$t\` (Jest + coverage)," ;;
test:all) EXTRA_LINE+=" \`$t\` (unit + integration)," ;;
*) EXTRA_LINE+=" \`$t\`," ;;
esac
done <<< "$EXTRA_TESTS"
# Remove trailing comma
EXTRA_LINE="${EXTRA_LINE%,}"
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@script/update-agents-md.sh` around lines 194 - 208, The EXTRA_LINE building
loop currently runs in a subshell (echo "$EXTRA_TESTS" | while ...) so updates
to EXTRA_LINE are lost; replace the pipeline with a non-subshell approach such
as using a here-string or process substitution (e.g., while IFS= read -r t; do
... done <<< "$EXTRA_TESTS" or done < <(printf '%s\n' "$EXTRA_TESTS")) so
mutations to EXTRA_LINE persist, ensure you reference
collect_extra_tests/EXTRA_TESTS/EXTRA_LINE exactly and remove or update the
hardcoded "extra tests" output later to use the dynamically built EXTRA_LINE (or
delete this block if you intentionally want the hardcoded text).

Comment on lines +277 to +293
if [[ "$CHECK_ONLY" == "true" ]]; then
# Write to temp file and format for accurate comparison
TMPFILE=$(mktemp /tmp/agents-md-check-XXXXX.md)
trap 'rm -f "$TMPFILE"' EXIT
echo "$NEW_CONTENT" > "$TMPFILE"
if command -v npx >/dev/null 2>&1; then
npx prettier --write "$TMPFILE" >/dev/null 2>&1 || true
fi
if ! diff -q "$AGENTS_MD" "$TMPFILE" >/dev/null 2>&1; then
echo "⚠️ AGENTS.md 自動生成セクションに差分があります"
diff "$AGENTS_MD" "$TMPFILE" | head -30
exit 1
else
echo "✅ AGENTS.md 自動生成セクション: 最新"
exit 0
fi
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

Use .context/ for temporary files instead of /tmp/.

The repository's operational rules require temporary files to be placed under .context/ rather than /tmp/ or OS-level temp directories. This ensures:

  • Other agents can access intermediate artifacts
  • Files are tracked and easier to clean up
  • Consistent behavior across environments
🔧 Proposed fix
 if [[ "$CHECK_ONLY" == "true" ]]; then
   # Write to temp file and format for accurate comparison
-  TMPFILE=$(mktemp /tmp/agents-md-check-XXXXX.md)
-  trap 'rm -f "$TMPFILE"' EXIT
+  mkdir -p .context
+  TMPFILE=$(mktemp .context/agents-md-check-XXXXX.md)
+  trap 'rm -f "$TMPFILE"' EXIT
   echo "$NEW_CONTENT" > "$TMPFILE"

Based on learnings: "Place all temporary and context files under .context/ in the repository root. Do NOT use /tmp/ or other OS-level temp directories."

📝 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
if [[ "$CHECK_ONLY" == "true" ]]; then
# Write to temp file and format for accurate comparison
TMPFILE=$(mktemp /tmp/agents-md-check-XXXXX.md)
trap 'rm -f "$TMPFILE"' EXIT
echo "$NEW_CONTENT" > "$TMPFILE"
if command -v npx >/dev/null 2>&1; then
npx prettier --write "$TMPFILE" >/dev/null 2>&1 || true
fi
if ! diff -q "$AGENTS_MD" "$TMPFILE" >/dev/null 2>&1; then
echo "⚠️ AGENTS.md 自動生成セクションに差分があります"
diff "$AGENTS_MD" "$TMPFILE" | head -30
exit 1
else
echo "✅ AGENTS.md 自動生成セクション: 最新"
exit 0
fi
fi
if [[ "$CHECK_ONLY" == "true" ]]; then
# Write to temp file and format for accurate comparison
mkdir -p .context
TMPFILE=$(mktemp .context/agents-md-check-XXXXX.md)
trap 'rm -f "$TMPFILE"' EXIT
echo "$NEW_CONTENT" > "$TMPFILE"
if command -v npx >/dev/null 2>&1; then
npx prettier --write "$TMPFILE" >/dev/null 2>&1 || true
fi
if ! diff -q "$AGENTS_MD" "$TMPFILE" >/dev/null 2>&1; then
echo "⚠️ AGENTS.md 自動生成セクションに差分があります"
diff "$AGENTS_MD" "$TMPFILE" | head -30
exit 1
else
echo "✅ AGENTS.md 自動生成セクション: 最新"
exit 0
fi
fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@script/update-agents-md.sh` around lines 277 - 293, Replace the use of OS
temp dir with a repo-scoped .context temp file: ensure .context exists (mkdir -p
.context) and create TMPFILE using mktemp with a .context prefix (e.g. mktemp
.context/agents-md-check-XXXXX.md), keep the trap to rm -f "$TMPFILE", write
NEW_CONTENT to "$TMPFILE", run npx prettier on "$TMPFILE" as before, and compare
TMPFILE with AGENTS_MD; update references to TMPFILE, CHECK_ONLY, NEW_CONTENT
and AGENTS_MD accordingly so all temporary artifacts live under .context/.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@keito4
keito4 merged commit 37cedca into main Mar 22, 2026
16 checks passed
@keito4
keito4 deleted the feat/agents-md-update-script branch March 22, 2026 14:49
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.105.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