Skip to content

Instantly share code, notes, and snippets.

@satyaborg
Created January 14, 2026 01:20
Show Gist options
  • Select an option

  • Save satyaborg/144b79235787e1d2d79c286af94f67bf to your computer and use it in GitHub Desktop.

Select an option

Save satyaborg/144b79235787e1d2d79c286af94f67bf to your computer and use it in GitHub Desktop.
Regenerate AGENTS.md when PR merges to main
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
@satyaborg
Copy link
Author

Next step is to add your Anthropic API key as a GitHub secret:

  1. Go to your repo on GitHub → Settings → Secrets and variables → Actions
  2. Click "New repository secret"
  3. Name: ANTHROPIC_API_KEY
  4. Value: your Anthropic API key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment