Created
June 21, 2026 11:00
-
-
Save ramsunvtech/bb46ecbc0f4fe694ae3ca6d194456800 to your computer and use it in GitHub Desktop.
Backend Claude MD Generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Regenerates the "Domain modules" section of CLAUDE.md from src/modules/*. | |
| # Everything outside the BEGIN/END markers is left untouched. | |
| # Run from the repo root: ./update-claude-md.sh | |
| set -euo pipefail | |
| FILE="CLAUDE.md" | |
| MODULES_DIR="src/modules" | |
| BEGIN="<!-- BEGIN:modules -->" | |
| END="<!-- END:modules -->" | |
| if [ ! -d "$MODULES_DIR" ]; then | |
| echo "Error: $MODULES_DIR not found. Run this from the repo root." >&2 | |
| exit 1 | |
| fi | |
| if [ ! -f "$FILE" ]; then | |
| echo "Error: $FILE not found in $(pwd). Create it first." >&2 | |
| exit 1 | |
| fi | |
| # Build the module list, comma-separated, sorted, no hidden dirs | |
| MODULE_LIST=$(find "$MODULES_DIR" -mindepth 1 -maxdepth 1 -type d \ | |
| -exec basename {} \; | sort | tr '\n' ',' | sed 's/,/, /g; s/, $//') | |
| # Build replacement block | |
| BLOCK="${BEGIN} | |
| ## Domain modules (\`${MODULES_DIR}/\`) | |
| ${MODULE_LIST} | |
| ${END}" | |
| if grep -q "$BEGIN" "$FILE" 2>/dev/null; then | |
| # Replace existing block between markers | |
| awk -v block="$BLOCK" -v begin="$BEGIN" -v end="$END" ' | |
| $0 ~ begin {print block; skip=1; next} | |
| $0 ~ end {skip=0; next} | |
| !skip {print} | |
| ' "$FILE" > "${FILE}.tmp" && mv "${FILE}.tmp" "$FILE" | |
| echo "Updated module list in $FILE" | |
| else | |
| # No markers yet — append block to end of file | |
| printf '\n%s\n' "$BLOCK" >> "$FILE" | |
| echo "Added module list block to $FILE" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment