Skip to content

Commit ed482e5

Browse files
jeremyederclaude
andcommitted
feat: Auto-sync CLAUDE.md during semantic-release
Couples CLAUDE.md updates to the release workflow, ensuring documentation stays in sync with each version release. **Changes**: - Created `scripts/sync-claude-md.sh` to update CLAUDE.md metrics - Syncs version number from semantic-release - Updates "Last Updated" date automatically - Pulls self-assessment score from latest assessment JSON - Uses simple sed patterns compatible across platforms - Updated `.releaserc.json` to execute sync script during prepare phase - Runs after pyproject.toml version bump - Includes CLAUDE.md in git commit assets - Ensures atomic version+docs updates **Benefits**: - Zero manual effort - happens automatically on every release - Version and docs always in sync (no more 23-version drift!) - Self-assessment score updated if new assessment available - Auditable via release commits **Testing**: - Verified script works locally with test version 1.24.0 - Confirmed all fields update correctly (version, date, score) - Tested on main branch CLAUDE.md (v1.0.0 baseline) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f06b2a8 commit ed482e5

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

.releaserc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[
1313
"@semantic-release/exec",
1414
{
15-
"prepareCmd": "sed -i 's/version = \".*\"/version = \"${nextRelease.version}\"/' pyproject.toml"
15+
"prepareCmd": "sed -i 's/version = \".*\"/version = \"${nextRelease.version}\"/' pyproject.toml && bash scripts/sync-claude-md.sh ${nextRelease.version}"
1616
}
1717
],
1818
[
@@ -29,7 +29,7 @@
2929
[
3030
"@semantic-release/git",
3131
{
32-
"assets": ["CHANGELOG.md", "pyproject.toml"],
32+
"assets": ["CHANGELOG.md", "pyproject.toml", "CLAUDE.md"],
3333
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
3434
}
3535
]

scripts/sync-claude-md.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
# Sync CLAUDE.md with current project metrics
3+
# Used by semantic-release during the release process
4+
5+
set -e
6+
7+
VERSION=${1:-$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')}
8+
TODAY=$(date +%Y-%m-%d)
9+
10+
echo "Syncing CLAUDE.md to version $VERSION (date: $TODAY)"
11+
12+
# Update all version numbers (simpler regex that works across different sed versions)
13+
sed -i.bak "s/v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/v$VERSION/g" CLAUDE.md
14+
sed -i.bak "s/\*\*AgentReady Version\*\*: [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/\*\*AgentReady Version\*\*: $VERSION/" CLAUDE.md
15+
16+
# Update "Last Updated" date at top (first occurrence only)
17+
awk -v today="$TODAY" '
18+
!updated && /\*\*Last Updated\*\*:/ {
19+
sub(/[0-9]{4}-[0-9]{2}-[0-9]{2}/, today);
20+
updated=1
21+
}
22+
{print}
23+
' CLAUDE.md > CLAUDE.md.tmp && mv CLAUDE.md.tmp CLAUDE.md
24+
25+
# Update "Last Updated" date at bottom (second occurrence)
26+
awk -v today="$TODAY" '
27+
/\*\*Last Updated\*\*:.*by Jeremy Eder/ {
28+
sub(/[0-9]{4}-[0-9]{2}-[0-9]{2}/, today);
29+
}
30+
{print}
31+
' CLAUDE.md > CLAUDE.md.tmp && mv CLAUDE.md.tmp CLAUDE.md
32+
33+
# Try to extract self-assessment score (if examples exist)
34+
if [ -f "examples/self-assessment/assessment-latest.json" ]; then
35+
SCORE=$(python3 -c "
36+
import json
37+
try:
38+
with open('examples/self-assessment/assessment-latest.json') as f:
39+
data = json.load(f)
40+
print(f\"{data['overall_score']}\")
41+
except Exception as e:
42+
print('unknown', file=sys.stderr)
43+
exit(1)
44+
" 2>/dev/null || echo "")
45+
46+
if [ -n "$SCORE" ] && [ "$SCORE" != "unknown" ]; then
47+
echo "Updating self-assessment score to $SCORE"
48+
# Update self-assessment scores (match any number with optional decimal)
49+
sed -i.bak "s/[0-9][0-9]*\.[0-9][0-9]*\/100/$SCORE\/100/g" CLAUDE.md
50+
fi
51+
fi
52+
53+
# Clean up backup files
54+
rm -f CLAUDE.md.bak
55+
56+
echo "✓ CLAUDE.md synced successfully"
57+
echo " - Version: $VERSION"
58+
echo " - Date: $TODAY"
59+
if [ -n "$SCORE" ]; then
60+
echo " - Self-Assessment: $SCORE/100"
61+
fi

0 commit comments

Comments
 (0)