A lightweight, repo-native agent that writes Cursor rules automatically for your project. Rule-Smith analyzes merged pull requests and generates documentation rules that help developers understand your codebase's patterns and practices.
When a pull request is merged, Rule-Smith:
- Analyzes the PR content, including title, description, and changed files
- Uses AI to understand the significance of the changes
- Generates a Cursor rule (
.mdc
file) that documents the changes - Creates a new PR with the generated rule
For example, if you merge a PR that adds error handling to API endpoints, Rule-Smith might generate a rule like:
# .cursor/rules/implement-error-handling.mdc
---
description: "Ensure all API endpoints implement proper error handling and logging"
globs:
- "src/api/**/*.ts"
alwaysApply: true
---
# Implement Error Handling
All API endpoints should:
- Use try/catch blocks for async operations
- Log errors with appropriate severity levels
- Return standardized error responses
- π€ Automated Documentation: Generates Cursor rules automatically when PRs are merged
- π Smart Analysis: Uses AI to understand PR context and generate meaningful rules
- π Well-Formatted Rules: Creates
.mdc
files with appropriate glob patterns - π GitHub Integration: Seamlessly integrates with GitHub Actions
- π οΈ Manual Mode: Supports both automated and manual rule generation
- Bun installed
- GitHub repository with Actions enabled
- OpenAI API key
-
Clone and install dependencies:
git clone https://github.com/yourusername/rule-smith.git cd rule-smith bun install
-
Create a
.env
file:GITHUB_TOKEN=your_github_token OPENAI_API_KEY=your_openai_api_key
-
Configure GitHub repository secrets:
GITHUB_TOKEN
(automatically provided by GitHub Actions)OPENAI_API_KEY
(your OpenAI API key)PERSONAL_ACCESS_TOKEN
(GitHub token with repo scope, for creating PRs)
The workflow is automatically configured. When you merge a PR to main:
- Rule-Smith analyzes the changes
- Generates appropriate Cursor rules
- Creates a new PR with the generated documentation
Simply merge your PRs to main! Rule-Smith will automatically:
- Analyze the changes
- Generate appropriate rules
- Create a new PR with the documentation
Generate rules for specific PRs:
GITHUB_REPOSITORY_OWNER=owner \
GITHUB_REPOSITORY=repo \
GITHUB_PR_NUMBER=123 \
bun run start
# Build the project
bun run build
# Run tests
bun test
# Lint code
bun run lint
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'feat: add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT