-
Notifications
You must be signed in to change notification settings - Fork 78
chore: 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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
51 changes: 51 additions & 0 deletions
51
...nstructions/setup-function-instead-of-beforeeach-in-unit-service-level-tests.md
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,51 @@ | ||
| --- | ||
| description: | ||
| globs: **/*.spec.tsx,**/*.spec.ts | ||
| alwaysApply: false | ||
| --- | ||
| ## Use setup function instead of beforeEach | ||
|
|
||
| ## Description | ||
| - Use `setup` function instead of `beforeEach` | ||
| - `setup` function must be at the bottom of the root `describe` block | ||
| - `setup` function creates an object under test and returns it | ||
| - `setup` function should accept a single parameter with inline type definition | ||
| - Don't use shared state in `setup` function | ||
| - Don't specify return type of `setup` function | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Good | ||
| ```typescript | ||
| describe("UserProfile", () => { | ||
| it("renders user name when provided", () => { | ||
| setup({ name: "John Doe" }); | ||
| expect(screen.queryByText("John Doe")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| function setup(input: { name?: string; email?: string; isLoading?: boolean; error?: string }) { | ||
| render(<UserProfile {...input} />); | ||
| return input; | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| ### Bad | ||
| ```typescript | ||
| describe("UserProfile", () => { | ||
| let props: UserProfileProps; | ||
|
|
||
| beforeEach(() => { | ||
| props = { name: "John Doe" }; | ||
| render(<UserProfile {...props} />); | ||
| }); | ||
|
|
||
| it("renders user name when provided", () => { | ||
| expect(screen.getByText("John Doe")).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
| ``` | ||
|
|
||
| ## References | ||
| - [DeploymentName.spec.tsx](mdc:apps/deploy-web/src/components/deployments/DeploymentName/DeploymentName.spec.tsx) | ||
| - https://github.com/akash-network/console/discussions/910 |
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,106 @@ | ||
| 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: volta-cli/action@v4 | ||
|
|
||
| - name: Generate CLAUDE.md | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
| run: | | ||
| node --experimental-strip-types --no-warnings script/generate-claude-md.ts | ||
|
|
||
| - name: Check for Changes | ||
| id: check-changes | ||
| run: | | ||
| if git diff --quiet CLAUDE.md .claude/instructions/; 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 .claude/instructions/ | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Contribution Guidelines | ||
|
|
||
| This file aggregates all RFC (Request for Comments) contribution guidelines that have landed. | ||
|
|
||
|
|
||
| ## `setup` function instead of `beforeEach` in unit & service level tests | ||
|
|
||
| See detailed guidelines: | ||
| @./.claude/instructions/setup-function-instead-of-beforeeach-in-unit-service-level-tests.md |
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.
Uh oh!
There was an error while loading. Please reload this page.