Rules
Rules are used to set AI’s coding style and project standards, making AI work according to your defined rules.
What is a Rule?
Section titled “What is a Rule?”A rule is a set of instructions that tell AI:
- 📝 Code style - What coding standards to use
- 🚫 Prohibitions - What operations are not allowed
- ✅ Best practices - What approaches are recommended
Selecting Rules
Section titled “Selecting Rules”Command
Section titled “Command”/ruleThen select the rule you want from the list.
Rule File Location
Section titled “Rule File Location”| Level | Location |
|---|---|
| User-level | ~/.carry/rules/ |
| Project-level | <project-dir>/.carry/rules/ |
Rule File Format
Section titled “Rule File Format”Basic Structure
Section titled “Basic Structure”# Project Rules
## Code Style- Use 2-space indentation- Use TypeScript, avoid any type- Functions must have comments
## Naming Conventions- Variables use camelCase- Constants use UPPER_SNAKE_CASE- Class names use PascalCase
## Prohibitions- Don't modify files in config directory- Don't use eval()- Don't commit sensitive information
## Best Practices- Prefer using const- Errors must be caught and handled- API interfaces must have type definitionsAdvanced Configuration
Section titled “Advanced Configuration”---name: my-project-ruledescription: My project rulesversion: 1.0---
# Rule content...AGENTS.md - Project-Specific Rules
Section titled “AGENTS.md - Project-Specific Rules”Create an AGENTS.md file in the project root to set project-specific rules.
Why Use AGENTS.md?
Section titled “Why Use AGENTS.md?”- 📁 Project-level config - Each project can have different rules
- 🤖 Team sharing - Team members automatically use the same standards
- 🔄 Version control - Rules can be committed to Git
Create AGENTS.md
Section titled “Create AGENTS.md”Create a file in the project root:
# Project Rules
## Code Style- Use 2-space indentation- Use TypeScript- Functions must have JSDoc comments
## Prohibitions- Don't modify node_modules- Don't delete test files- Don't commit .env files
## Git Commit Standards- Use Conventional Commits format- Must run tests before committingHow AI Uses AGENTS.md
Section titled “How AI Uses AGENTS.md”When you ask AI to modify code, it will automatically:
- Read
AGENTS.mdin the project root - Understand the rules
- Generate code according to the rules
Built-in Rules
Section titled “Built-in Rules”CarryCodevides these built-in rules:
| Rule Name | Description |
|---|---|
default | Default rules |
strict | Strict mode |
relaxed | Relaxed mode |
Rule Priority
Section titled “Rule Priority”Carry Code applies rules in this priority order:
- AGENTS.md (project root)
- Project-level rules (
.carry/rules/) - User-level rules (
~/.carry/rules/)
Higher priority overrides lower priority.
Usage Examples
Section titled “Usage Examples”Example 1: Set Code Style
Section titled “Example 1: Set Code Style”Create rules requiring 4-space indentation:
## Code Style- Use 4-space indentation- Maximum 100 characters per lineExample 2: Protect Critical Files
Section titled “Example 2: Protect Critical Files”## Prohibitions- Don't modify src/config/ directory- Don't delete .git directory- Don't modify package-lock.jsonExample 3: Enforce Testing
Section titled “Example 3: Enforce Testing”## Best Practices- All new functions must include tests- Run tests before modifying code- Test coverage must not be below 80%Managing Rules
Section titled “Managing Rules”View Current Rules
Section titled “View Current Rules”/ruleThe currently used rule is displayed in the interface.
Switch Rules
Section titled “Switch Rules”/rule <rule-name>Create New Rules
Section titled “Create New Rules”Create a new .md file in the rules directory:
~/.carry/rules/my-rule.mdQ: What’s the difference between AGENTS.md and /rule?
Section titled “Q: What’s the difference between AGENTS.md and /rule?”| Feature | AGENTS.md | /rule |
|---|---|---|
| Scope | Current project | Global |
| Location | Project root | ~/.carry/rules/ |
| Version control | Committed with project | Local |
Q: Will rules affect AI answering questions?
Section titled “Q: Will rules affect AI answering questions?”No. Rules are mainly used for code generation and modification.
Q: Can I not set rules?
Section titled “Q: Can I not set rules?”Yes. When no rules are set, AI will work in the default way.
Next Steps
Section titled “Next Steps”- Themes - Customize the interface appearance
- Approval Modes - Control AI permissions
- Command Reference - All commands