A powerful CLI toolkit for extending and enhancing AI capabilities through customizable rules and commands.
Project description
ai-rules [WIP]
🛠️ A powerful CLI toolkit for extending and enhancing AI capabilities through customizable rules and commands.
Transform your AI assistants (Cursor, Windsurf, Cline) into more capable development companions by crafting specialized instruction sets and custom commands.
Inspiration
This project is inspired by devin.cursorrules and the blog post Turning $20 into $500 - Transforming Cursor into Devin in One Hour. We extend these ideas by providing a systematic way to manage and enhance AI rules across different platforms.
Key Features
- 🧠 Extend AI capabilities through custom rules and commands
- 🔌 Plugin system for adding new AI functionalities
- 🌍 Support multiple AI platforms (Cursor, Windsurf, Cline)
- 🤖 LLM-powered tools (search, translation, etc.)
- 📝 Global and workspace-specific rule management
- ⚡ Command extension system for AI enhancement
Installation
pip install ai-rules
Quick Start
Initialize AI Assistant Rules
# Initialize rules for Windsurf
uvx ai-rules init windsurf
# Initialize rules for Cursor
uvx ai-rules init cursor
# Initialize rules for CLI
uvx ai-rules init cli
Use Built-in Plugins
# Search the web
uvx ai-rules plugin search "Python best practices" --limit 5
# Translate text
uvx ai-rules plugin translate "Hello World" --target-lang zh
Plugin Development Guide
Creating a Custom Plugin
-
Create a new Python file in one of these locations:
- Built-in plugins:
src/ai_rules/plugins/ - User plugins:
~/.ai-rules/plugins/ - Virtual environment plugins:
venv/lib/ai-rules/plugins/
- Built-in plugins:
-
Implement your plugin by inheriting from the Plugin base class:
from ai_rules.core.plugin import Plugin
import click
class MyCustomPlugin(Plugin):
"""Your custom plugin description."""
name = "my_plugin" # Command name
description = "Description of what your plugin does"
def get_command_spec(self) -> dict:
"""Define command line parameters."""
return {
"params": [
{
"name": "input_text",
"type": click.STRING,
"required": True,
"help": "Input text to process"
},
{
"name": "option1",
"type": click.INT,
"required": False,
"default": 42,
"help": "An optional parameter"
}
]
}
def execute(self, input_text: str, option1: int = 42) -> Any:
"""Execute plugin functionality.
Args match the parameters defined in get_command_spec().
"""
# Your plugin logic here
result = f"Processed {input_text} with option {option1}"
return result
Plugin Requirements
- Base Class: Must inherit from
Plugin - Required Attributes:
name: Plugin command namedescription: Plugin description
- Required Methods:
get_command_spec(): Define command parametersexecute(): Implement plugin logic
Parameter Types
The following Click types are supported:
click.STRING: Text inputclick.INT: Integer numbersclick.FLOAT: Floating point numbersclick.BOOL: Boolean flagsclick.Choice(['a', 'b']): Choice from options- More types in Click documentation
Example Plugins
Check out our example plugins for reference:
- Search Plugin: Web search functionality
- Translate Plugin: Text translation
- Weather Plugin: Weather information
Using Your Plugin
Once installed, your plugin will be automatically discovered and registered:
# List available plugins
uvx ai-rules plugin --help
# Run your plugin
uvx ai-rules plugin my_plugin "input text" --option1 123
Documentation
Command Structure
- Initialize Rules
uvx ai-rules init <assistant-type>
assistant-type: windsurf, cursor, or cli- Creates configuration files in the current directory
- Use Plugins
uvx ai-rules plugin <plugin-name> [arguments]
Development
Project Structure
src/ai_rules/
├── core/
│ ├── plugin.py # Plugin system
│ ├── template.py # Template conversion
│ └── __init__.py
├── plugins/ # Built-in plugins
├── templates/ # Rule templates
├── cli.py # CLI implementation
└── __init__.py
Contributing
Contributions are welcome! Please read our Contributing Guidelines first.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_rules-0.1.1.tar.gz.
File metadata
- Download URL: ai_rules-0.1.1.tar.gz
- Upload date:
- Size: 73.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1047b06920b57ecc028a82a5c63936e37087315cbaceea9a87c285fadb9d03f9
|
|
| MD5 |
c62b4813f917a20e7c44d056da8830b9
|
|
| BLAKE2b-256 |
60a38d9463f0396939046d5366c264524bf26d53aae7f5276b32ffede963aff3
|
Provenance
The following attestation bundles were made for ai_rules-0.1.1.tar.gz:
Publisher:
python-publish.yml on loonghao/ai-rules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_rules-0.1.1.tar.gz -
Subject digest:
1047b06920b57ecc028a82a5c63936e37087315cbaceea9a87c285fadb9d03f9 - Sigstore transparency entry: 161956052
- Sigstore integration time:
-
Permalink:
loonghao/ai-rules@36eabe0ba17db19b2c7e073c3c040075a305b625 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/loonghao
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@36eabe0ba17db19b2c7e073c3c040075a305b625 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ai_rules-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ai_rules-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b911e7b49fd25a79cdb71b2f604f73b9db975722d362442a9e703444e3de4064
|
|
| MD5 |
2054b51aa28e58e6f49b3ee4e907dfa3
|
|
| BLAKE2b-256 |
8ccf612c513404d6e71353cd564e559c0034a4eee4c1f25f08e45023a6a900bc
|
Provenance
The following attestation bundles were made for ai_rules-0.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on loonghao/ai-rules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_rules-0.1.1-py3-none-any.whl -
Subject digest:
b911e7b49fd25a79cdb71b2f604f73b9db975722d362442a9e703444e3de4064 - Sigstore transparency entry: 161956053
- Sigstore integration time:
-
Permalink:
loonghao/ai-rules@36eabe0ba17db19b2c7e073c3c040075a305b625 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/loonghao
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@36eabe0ba17db19b2c7e073c3c040075a305b625 -
Trigger Event:
push
-
Statement type: