feat: AGENTS.md 自動生成スクリプトを追加し repo-maintenance に組み込み - #615
Conversation
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>
📝 WalkthroughWalkthroughThis PR introduces automated AGENTS.md regeneration infrastructure via a new Bash script ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Important Merge conflicts detected (Beta)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
🔍 AI Code Review (Local Hook)Models: Codex (default) / Gemini (default) 🤖 Codex Review以下は、
判定: patch is incorrect
|
There was a problem hiding this comment.
💡 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' |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 👍 / 👎.
|
test |
Test |
|
コードレビュー |
コードレビューバグ問題 |
コードレビューPR の方針(手動編集 → スクリプト自動生成)は良いアプローチです。以下にフィードバックをまとめます。 バグ・ロジック問題1. EXTRA_LINE が dead code(script/update-agents-md.sh)
加えて echo EXTRA_TESTS | while ... はパイプでサブシェルが生成されるため、ループ内の EXTRA_LINE+= は外部に伝播しません(bash のパイプサブシェル問題)。 提案: ドキュメント品質の後退2. CI/CD Workflows の説明が大幅に短縮ワークフロー 提案: YAML の 3. Available Commands の説明が (no description) だらけfrontmatter に /tmp/ の使用(CLAUDE.md ルール)
良い点
まとめ最重要修正は EXTRA_LINE の dead code(削除か機能させるかどちらか)です。CI/CD 説明の品質後退はトレードオフですが Generated with Claude Code |
Actions を SHA 固定したことにより、`@v6` や `@v7` のタグ参照を 期待していた BATS テストが失敗していた。 `@` の後にタグまたは SHA が続くパターンに変更。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
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
@latestwould 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@latestfloating ref.The change from
@vNto@correctly accommodates SHA-pinned actions (which are more secure than version tags). The existing negative assertions on lines 57-58 catch@mainand@master.However,
@latestis 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 '|') 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
📒 Files selected for processing (5)
.claude/commands/repo-maintenance.mdAGENTS.mdscript/update-agents-md.shtest/integration/coverage-report-workflow.batstest/integration/workflows.bats
| | 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 | | ||
|
|
There was a problem hiding this comment.
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.
| | 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.
| # --- 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" | ||
| } |
There was a problem hiding this comment.
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.
| # --- 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 '|') 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.
| # 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 |
There was a problem hiding this comment.
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.
| # 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).
| 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 |
There was a problem hiding this comment.
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.
| 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>
|
🎉 This PR is included in version 1.105.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
script/update-agents-md.shを追加: AGENTS.md の自動生成セクションをリポジトリの現在の状態から再生成するスクリプト/repo-maintenanceの Step 3.4.1 を「参考ロジック」からスクリプト呼び出しに変更背景
これまで AGENTS.md の自動生成セクション更新は、repo-maintenance 実行時に Claude が手動で判断・編集していました。そのため、ディレクトリ追加やワークフロー変更が反映漏れになる問題がありました。
script/update-agents-md.sh の仕様
--checkモードnix/flake.nixの存在を検出して macOS Environment を追記repo-maintenance での使い方
bash script/update-agents-md.shで更新を適用bash script/update-agents-md.sh --checkで差分を報告のみTest plan
bash script/update-agents-md.sh→ 正常に再生成bash script/update-agents-md.sh --check→ exit 0(冪等性確認)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests