Created
January 14, 2026 01:20
-
-
Save satyaborg/144b79235787e1d2d79c286af94f67bf to your computer and use it in GitHub Desktop.
Regenerate AGENTS.md when PR merges to main
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
| name: Update AGENTS.md | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-agents: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Claude Code | |
| run: npm install -g @anthropic-ai/claude-code | |
| - name: Run init and setup AGENTS.md | |
| env: | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| run: | | |
| # Remove existing CLAUDE.md so /init generates fresh content | |
| rm -f CLAUDE.md | |
| # Run init to create CLAUDE.md with full content | |
| claude --dangerously-skip-permissions /init | |
| # Move full content to AGENTS.md and replace CLAUDE.md with reference | |
| mv CLAUDE.md AGENTS.md | |
| echo "@AGENTS.md" > CLAUDE.md | |
| - name: Commit changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add AGENTS.md CLAUDE.md | |
| git diff --staged --quiet || git commit -m "chore: update AGENTS.md via CI" | |
| git push |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Next step is to add your Anthropic API key as a GitHub secret: