Bytecode Rules

Define and enforce custom coding standards, best practices, and team conventions with intelligent rule systems.

Bytecode Rules allow you to establish and maintain consistent coding standards across your projects and team. These intelligent rules guide AI assistance to follow your specific conventions, enforce best practices, and ensure code quality while adapting to your unique development requirements.

Types of Rules

Code Style Rules
  • Formatting: Indentation, spacing, line breaks
  • Naming: Variable, function, and class naming conventions
  • Structure: File organization and import ordering
  • Comments: Documentation and comment standards
ESLintPrettierCustom
Security Rules
  • Input validation: Sanitization and validation patterns
  • Authentication: Secure auth implementation guidelines
  • Data handling: Sensitive data protection rules
  • Dependencies: Approved packages and versions
OWASPSASTCustom
Architecture Rules
  • Design patterns: Preferred architectural patterns
  • Dependencies: Module dependency guidelines
  • Testing: Test coverage and structure requirements
  • Performance: Optimization and efficiency standards
Clean CodeSOLIDDRY

How Rules Work

Rule Definition
  • Natural language: Describe rules in plain English
  • Code examples: Provide good and bad examples
  • Context-aware: Rules apply to specific file types or projects
  • Severity levels: Error, warning, or suggestion
Rule Enforcement
  • Real-time checking: Rules applied as you code
  • AI guidance: Suggestions follow your rules
  • Auto-correction: Automatic fixes for simple violations
  • Integration: Works with existing linters and tools

Rule Categories

Project-Level Rules
Apply to entire projects or repositories
  • • Technology stack preferences
  • • File structure and organization
  • • Build and deployment standards
  • • Documentation requirements
  • • Git workflow conventions
Team-Level Rules
Shared across team members and projects
  • • Coding style guidelines
  • • Code review standards
  • • Testing methodologies
  • • Security best practices
  • • Performance benchmarks
Language-Specific Rules
Tailored to specific programming languages
  • • JavaScript/TypeScript conventions
  • • Python PEP standards
  • • Java coding guidelines
  • • C++ best practices
  • • Framework-specific rules
Personal Rules
Individual developer preferences
  • • Personal coding style
  • • Preferred libraries and tools
  • • Custom shortcuts and templates
  • • Learning objectives
  • • Productivity preferences

Example Rules

React Component Rule

Rule:

"All React components must use TypeScript, include proper prop types, and follow the compound component pattern for complex UI elements."

Good Example:

interface ButtonProps {
  variant: 'primary' | 'secondary';
  children: React.ReactNode;
}
API Security Rule

Rule:

"All API endpoints must include authentication, input validation, rate limiting, and proper error handling with sanitized responses."

Bad Example:

app.get('/user/:id', (req, res) => {
  // No auth or validation
  return db.user.find(req.params.id);
});

Benefits

For Teams
  • Consistency: Uniform code style across all team members
  • Quality: Automated enforcement of best practices
  • Onboarding: New team members learn standards quickly
  • Reviews: Faster code reviews with fewer style discussions
  • Maintenance: Easier to maintain and update codebases
For Individuals
  • Learning: AI teaches best practices through rules
  • Productivity: Automated adherence to standards
  • Growth: Continuous improvement through rule evolution
  • Confidence: Know your code follows best practices
  • Focus: Spend time on logic, not style decisions

Managing Rules

Creating Rules
  • • Use the `/rule` command
  • • Import from existing configs
  • • Learn from code examples
  • • Copy from rule templates
Organizing Rules
  • • Group by category or project
  • • Set priority and severity levels
  • • Enable/disable as needed
  • • Version control rule changes
Sharing Rules
  • • Export rule sets for teams
  • • Sync across development environments
  • • Publish to rule marketplace
  • • Import community rule sets
Getting Started with Rules
  1. 1. Start simple: Begin with basic style rules like naming conventions
  2. 2. Learn from examples: Use existing rule templates as starting points
  3. 3. Iterate gradually: Add more complex rules as your team adapts
  4. 4. Get team buy-in: Involve team members in rule creation and refinement
  5. 5. Monitor and adjust: Regularly review rule effectiveness and update as needed