-
Notifications
You must be signed in to change notification settings - Fork 77
feat: automate CLAUDE.md generation from RFC discussions #2199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/generate-claude-md-file
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a278b61
Initial plan
Copilot 71e13cd
feat: add CLAUDE.md generation workflow and script
Copilot b1e7e69
docs: add README for contribution-guidelines directory
Copilot bc1e4f6
docs: add AI guidelines section to CONTRIBUTING.md
Copilot 4a9b7e9
refactor: rewrite script in TypeScript and simplify workflow
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Contribution Guidelines | ||
|
|
||
| This directory contains AI instructions extracted from RFC (Request for Comments) discussions that have been approved and landed in the project. | ||
|
|
||
| ## How It Works | ||
|
|
||
| This directory is automatically maintained by the GitHub Actions workflow `.github/workflows/generate-claude-md.yml`. The workflow: | ||
|
|
||
| 1. Monitors discussions in the "Contribution RFC" category | ||
| 2. When a discussion receives the `RFC:Landed` label, its "## AI Instructions" section is extracted | ||
| 3. Creates/updates a markdown file in this directory with the extracted content | ||
| 4. Generates the root `CLAUDE.md` file with links to all RFC files | ||
| 5. Creates a PR for human review | ||
|
|
||
| ## File Naming Convention | ||
|
|
||
| RFC files are named based on the discussion title: | ||
| - Convert to lowercase | ||
| - Replace spaces with hyphens | ||
| - Remove special characters | ||
|
|
||
| Example: "Testing Strategy" → `testing-strategy.md` | ||
|
|
||
| ## Structure | ||
|
|
||
| Each RFC file contains: | ||
| - Title of the RFC as a header | ||
| - AI Instructions extracted from the discussion | ||
|
|
||
| ## Adding New RFCs | ||
|
|
||
| To add a new RFC to this system: | ||
|
|
||
| 1. Create or edit a discussion in the "Contribution RFC" category | ||
| 2. Add a section titled `## AI Instructions` with the guidance for AI coding assistants | ||
| 3. Add the `RFC:Landed` label to the discussion | ||
| 4. The workflow will automatically create a PR with the changes | ||
|
|
||
| ## Removing RFCs | ||
|
|
||
| To remove an RFC: | ||
| 1. Remove the `RFC:Landed` label from the discussion | ||
| 2. The workflow will automatically create a PR that removes the file | ||
|
|
||
| ## Manual Updates | ||
|
|
||
| While files are auto-generated, if you need to make manual corrections: | ||
| 1. Edit the source discussion on GitHub | ||
| 2. The workflow will regenerate the files on the next trigger |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| name: Generate CLAUDE.md | ||
|
|
||
| on: | ||
| discussion: | ||
| types: [labeled, unlabeled, edited] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| env: | ||
| CONTRIBUTION_BRANCH: automated/claude-md-update | ||
|
|
||
| jobs: | ||
| generate: | ||
| name: Generate CLAUDE.md | ||
| if: github.event.discussion.category.name == 'Contribution RFC' | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: main | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22.14.0 | ||
|
|
||
| - name: Generate CLAUDE.md | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
| run: | | ||
| node --experimental-strip-types script/generate-claude-md.ts | ||
|
|
||
| - name: Check for Changes | ||
| id: check-changes | ||
| run: | | ||
| if git diff --quiet CLAUDE.md .contribution-guidelines/; then | ||
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | ||
| echo "No changes detected" | ||
| else | ||
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | ||
| echo "Changes detected" | ||
| fi | ||
|
|
||
| - name: Configure Git | ||
| if: steps.check-changes.outputs.has_changes == 'true' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Commit and Push Changes | ||
| if: steps.check-changes.outputs.has_changes == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| # Create or switch to the branch | ||
| git fetch origin "${{ env.CONTRIBUTION_BRANCH }}" 2>/dev/null || true | ||
| git checkout -B "${{ env.CONTRIBUTION_BRANCH }}" | ||
|
|
||
| # Stage and commit changes | ||
| git add CLAUDE.md .contribution-guidelines/ | ||
| git commit -m "chore: update CLAUDE.md from RFC discussions" \ | ||
| -m "Discussion #${{ github.event.discussion.number }} was ${{ github.event.action }}" | ||
|
|
||
| # Push changes | ||
| git push -f origin "${{ env.CONTRIBUTION_BRANCH }}" | ||
|
|
||
| - name: Create or Update Pull Request | ||
| if: steps.check-changes.outputs.has_changes == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| # Check if PR already exists | ||
| PR_NUMBER=$(gh pr list \ | ||
| --base main \ | ||
| --head "${{ env.CONTRIBUTION_BRANCH }}" \ | ||
| --state open \ | ||
| --limit 1 \ | ||
| --json number \ | ||
| --jq ".[0].number" || echo "") | ||
|
|
||
| if [ -z "$PR_NUMBER" ]; then | ||
| echo "Creating new PR..." | ||
|
|
||
| # Create PR body | ||
| printf "This PR automatically updates CLAUDE.md and contribution guidelines based on RFC discussions.\n\n" > /tmp/pr-body.md | ||
| printf "Triggered by: Discussion #%s (%s)\n\n" "${{ github.event.discussion.number }}" "${{ github.event.action }}" >> /tmp/pr-body.md | ||
| printf "Changes:\n- Generated/updated CLAUDE.md\n- Updated RFC files in .contribution-guidelines/\n\n" >> /tmp/pr-body.md | ||
| printf "Review Notes:\n- Verify that the extracted AI Instructions are correct\n" >> /tmp/pr-body.md | ||
| printf -- "- Check that all RFC:Landed discussions are included\n" >> /tmp/pr-body.md | ||
| printf -- "- Ensure removed RFCs are properly cleaned up\n" >> /tmp/pr-body.md | ||
|
|
||
| gh pr create \ | ||
| --base main \ | ||
| --head "${{ env.CONTRIBUTION_BRANCH }}" \ | ||
| --title "chore: update CLAUDE.md from RFC discussions" \ | ||
| --body-file /tmp/pr-body.md | ||
| else | ||
| echo "PR #$PR_NUMBER already exists and has been updated" | ||
| fi | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue(blocking): can you commit using
gitcli tool, this will be much simplerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 4a9b7e9. Simplified the workflow to use git CLI for commits with
git commitandgit pushinstead of the GitHub API.