Created
February 24, 2026 06:57
-
-
Save Alex4386/8f5d817035656b83265b09ef72e3ce59 to your computer and use it in GitHub Desktop.
Codex AGENTS.md builder for SuperClaude migration
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 sh | |
| set -eu | |
| SOURCE_DIR="$HOME/.codex/agents" | |
| OUTPUT_FILE="AGENTS.md" | |
| # Verify source directory exists | |
| if [ ! -d "$SOURCE_DIR" ]; then | |
| echo "Error: Source directory '$SOURCE_DIR' does not exist." >&2 | |
| exit 1 | |
| fi | |
| # Create a temporary file for atomic write | |
| TMP_FILE="$(mktemp)" | |
| # Track whether any files were processed | |
| FOUND=0 | |
| # Deterministic ordering | |
| for FILE in $(find "$SOURCE_DIR" -type f -name "*.md" | sort); do | |
| if [ -f "$FILE" ]; then | |
| FOUND=1 | |
| printf "\n<!-- Begin: %s -->\n\n" "$FILE" >> "$TMP_FILE" | |
| cat "$FILE" >> "$TMP_FILE" | |
| printf "\n<!-- End: %s -->\n\n" "$FILE" >> "$TMP_FILE" | |
| fi | |
| done | |
| if [ "$FOUND" -eq 0 ]; then | |
| echo "Error: No markdown files found in '$SOURCE_DIR'." >&2 | |
| rm -f "$TMP_FILE" | |
| exit 1 | |
| fi | |
| # Atomic replace | |
| mv "$TMP_FILE" "$OUTPUT_FILE" | |
| echo "Merged markdown files into $OUTPUT_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment