Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Implements GitHub Actions automation to generate CLAUDE.md from RFC discussions labeled RFC:Landed, providing AI coding assistants with project-specific contribution guidelines.

Changes

Script: script/generate-claude-md.ts

  • TypeScript implementation using Node.js --experimental-strip-types for direct execution
  • Fetches discussions from "Contribution RFC" category via gh cli GraphQL API
  • Extracts ## AI Instructions sections from RFC:Landed discussions
  • Generates individual RFC files in .claude/instructions/ with lowercase-dashed naming
  • Builds root CLAUDE.md with @.contribution-guidelines/[filename].md links
  • Removes obsolete files when labels are removed
  • Type-safe with proper interfaces for API responses

Workflow: .github/workflows/generate-claude-md.yml

  • Triggers: discussion labeled, unlabeled, edited events
  • Filters: "Contribution RFC" category using github.event.discussion.category.name from event context
  • Uses git CLI (git commit, git push) for commits instead of GitHub API
  • Creates PR to automated/claude-md-update branch (no direct commits)
  • Single streamlined job with Node.js 22.14.0 setup

Documentation

  • .contribution-guidelines/README.md: System overview and usage
  • CONTRIBUTING.md: Added AI Coding Guidelines section

Example Output

When an RFC titled "Testing Strategy" gets the RFC:Landed label:

Generated .contribution-guidelines/testing-strategy.md:

# Testing Strategy

[Content from ## AI Instructions section]

Generated CLAUDE.md:

# Contribution Guidelines

## Testing Strategy

@.contribution-guidelines/testing-strategy.md

Usage

  1. Create discussion in "Contribution RFC" category
  2. Add ## AI Instructions section with guidance for AI tools
  3. Apply RFC:Landed label
  4. Workflow creates PR with generated files for review
Original prompt

This section details on the original issue you should resolve

<issue_title>generate CLAUDE.md file from contibution guidelines</issue_title>
<issue_description>## Why

CLAUDE.md is a file which gives context to different coding agents like copilot, cursor and some others. This file helps them to understand the project better and create PRs/generate code of better quality.

What

Generate CLAUDE.md from https://github.com/akash-network/console/discussions/categories/contribution-rfc?discussions_q=is%3Aopen+category%3A%22Contribution+RFC%22 using GHA.

For every discussion, we will use a separate file and will link it into root CLAUDE.md with a reference to that file. All sub-files will live in .contribution-guidelines folder. Every file has the same title as RFC discussion (lowercased with spaces replaced by dashes).

Implementation Details

AI Instructions Section in RFCs

Each RFC discussion must include a dedicated section called ## AI Instructions. The author of the RFC needs to add this section before changing the label to RFC:Landed. This section will contain instructions that will be extracted and included in the CLAUDE.md file.

Note: Currently, RFCs don't have this section. It needs to be added manually to existing RFC:Landed discussions.

GitHub Actions Automation

The automation script should be implemented in bash using gh cli and will:

  1. Trigger on these discussion events:

    • labeled - when RFC:Landed label is added, create new file
    • unlabeled - when RFC:Landed label is removed, delete the file
    • edited - when discussion is edited, recreate (update) the file
  2. Process:

    • Regenerate the entire CLAUDE.md structure on every event
    • Only update files that were actually modified
    • Create a PR with the changes for review (don't commit directly)

Root CLAUDE.md Structure

The root CLAUDE.md file should have the following structure:

## <RFC title>

@.contribution-guidelines/rfc-title.md  # lowercased, dashed

File Naming Convention

RFC discussion titles should be converted to filenames using this rule:

  • Convert to lowercase
  • Replace spaces with hyphens
  • Remove special characters

Example: "Testing Strategy" → testing-strategy.md

Workflow

  1. GHA monitors discussions in the "Contribution RFC" category
  2. When a discussion receives/loses the RFC:Landed label or is edited, the workflow triggers
  3. Script extracts the ## AI Instructions section from all RFC:Landed discussions
  4. Generates/updates files in .contribution-guidelines/ directory
  5. Generates root CLAUDE.md with links to all sub-files
  6. Creates a PR with changes for human review</issue_description>

<agent_instructions>follow repository rules from .cursor/rules folder and patterns from .github/workflows</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@stalniy @coderabbitai did I miss something, is the task clear? if not, please update the description @stalniy 1. Let's call this section "## AI Instructions". Currently RFCs doesn't have this section, we need to add it manually, people will do this. 2. We can completely regenerate Claude.md file on every `labeled`, `unlabeled`, `edited` events on discussions of that specific category. The script can be implemented in bash with help of `gh cli`. We also need to update corresponding files but only if they were modified. When discussion receives required label then new file added, when discussion looses that label - file is removed. When discussion is edited file is recreated (basically updated) 3. Root CLAUDE.md will have a structure like this:
## <RFC title>

@.contribution-guidelines/rfc-title.md  # lowercased, dashed

Automated gha must create a PR which then will be reviewed by people </comment_new>
<comment_new>@stalniy
@coderabbitai, please update the issue description with details I've added in #2198 (comment)</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Generate CLAUDE.md file from contribution guidelines feat: automate CLAUDE.md generation from RFC discussions Nov 11, 2025
Copilot AI requested a review from stalniy November 11, 2025 11:18
@stalniy stalniy force-pushed the copilot/generate-claude-md-file branch from 0e47e98 to 5cba863 Compare January 13, 2026 05:14
}

function writeAiInstruction(filepath: string, aiInstructions: string): void {
writeFileSync(filepath, aiInstructions, "utf-8");
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: we could also generate here cursor/copilot rules

@stalniy stalniy marked this pull request as ready for review January 13, 2026 05:15
@stalniy stalniy requested a review from a team as a code owner January 13, 2026 05:15
Signed-off-by: Serhii Stotskyi <[email protected]>
@stalniy stalniy changed the title feat: automate CLAUDE.md generation from RFC discussions chore: automate CLAUDE.md generation from RFC discussions Jan 13, 2026
@stalniy stalniy merged commit bb5009c into main Jan 13, 2026
59 of 67 checks passed
@stalniy stalniy deleted the copilot/generate-claude-md-file branch January 13, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generate CLAUDE.md file from contibution guidelines

3 participants