Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .contribution-guidelines/README.md
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
108 changes: 108 additions & 0 deletions .github/workflows/generate-claude-md.yml
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: |
Copy link
Contributor

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 git cli tool, this will be much simpler

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix this

Copy link
Contributor Author

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 commit and git push instead of the GitHub API.

# 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
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,20 @@ If you're ready to contribute, follow our guidelines:

Note that this process allows multiple developers to collaborate effectively and maintain high-quality code for a long-lasting entity; the project.

### AI Coding Guidelines

This repository uses AI-assisted coding tools (GitHub Copilot, Cursor, Claude, etc.). To help these tools generate better code:

- **CLAUDE.md**: Contains aggregated contribution guidelines extracted from approved RFCs
- **Contribution RFCs**: Guidelines are sourced from discussions in the [Contribution RFC category](https://github.com/akash-network/console/discussions/categories/contribution-rfc)
- **Auto-Generated**: The CLAUDE.md file is automatically generated when RFC discussions receive the `RFC:Landed` label

To contribute new AI guidelines:
1. Create a discussion in the "Contribution RFC" category
2. Include a section titled `## AI Instructions` with guidance for AI coding assistants
3. Once approved, add the `RFC:Landed` label
4. The guidelines will be automatically added to CLAUDE.md

See [`.contribution-guidelines/README.md`](./.contribution-guidelines/README.md) for more details.

*That your commitment to following these specs will make a difference.*
Loading