Skip to content

Rules

Rules are used to set AI’s coding style and project standards, making AI work according to your defined rules.


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

/rule

Then select the rule you want from the list.

LevelLocation
User-level~/.carry/rules/
Project-level<project-dir>/.carry/rules/

# 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 definitions
---
name: my-project-rule
description: My project rules
version: 1.0
---
# Rule content
...

Create an AGENTS.md file in the project root to set project-specific rules.

  • 📁 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 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 committing

When you ask AI to modify code, it will automatically:

  1. Read AGENTS.md in the project root
  2. Understand the rules
  3. Generate code according to the rules

CarryCodevides these built-in rules:

Rule NameDescription
defaultDefault rules
strictStrict mode
relaxedRelaxed mode

Carry Code applies rules in this priority order:

  1. AGENTS.md (project root)
  2. Project-level rules (.carry/rules/)
  3. User-level rules (~/.carry/rules/)

Higher priority overrides lower priority.


Create rules requiring 4-space indentation:

## Code Style
- Use 4-space indentation
- Maximum 100 characters per line
## Prohibitions
- Don't modify src/config/ directory
- Don't delete .git directory
- Don't modify package-lock.json
## Best Practices
- All new functions must include tests
- Run tests before modifying code
- Test coverage must not be below 80%

/rule

The currently used rule is displayed in the interface.

/rule <rule-name>

Create a new .md file in the rules directory:

~/.carry/rules/my-rule.md

Q: What’s the difference between AGENTS.md and /rule?

Section titled “Q: What’s the difference between AGENTS.md and /rule?”
FeatureAGENTS.md/rule
ScopeCurrent projectGlobal
LocationProject root~/.carry/rules/
Version controlCommitted with projectLocal

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.

Yes. When no rules are set, AI will work in the default way.