agentleFS
donvitodonvito/ai-backends/.cursor/rules/coding-standards.mdc

ai-backends / rules

Cursor rule146 starsChanged 14 months agoApache-2.0View on GitHub

This document outlines coding standards and best practices for the AI Backends project.

  • Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.

    Of the Cursor rule files we read, the 4,157 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

Show its rules and text

We split this coding-standards.mdc into the rules it gives an agent

15 rules. About 0 are common, 14 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use proper TypeScript types and avoid any when possible

    line 12
  2. Distinctive:

    Create interfaces for complex data structures

    line 13
  3. Distinctive:

    Use type guards when necessary for type narrowing

    line 14
  4. Distinctive:

    Follow RESTful principles for resource-based endpoints

    line 19
  5. Distinctive:

    Use consistent naming conventions for endpoints

    line 20
  6. Distinctive:

    Document APIs using OpenAPI/Swagger via Hono's built-in support

    line 21
  7. Distinctive:

    Use consistent error handling patterns

    line 28
  8. Distinctive:

    Create custom error classes when appropriate

    line 30
  9. Distinctive:

    Don't expose sensitive information in error messages

    line 32
  10. Distinctive:

    Avoid blocking operations when possible

    line 36
  11. Distinctive:

    Use caching where appropriate

    line 37
  12. Distinctive:

    Consider rate limiting for resource-intensive operations

    line 38
  13. Distinctive:

    Follow the principle of least privilege

    line 47
  14. Distinctive:

    Consider streaming responses for long-running AI operations

    line 55
  15. Distinctive:

    Use the reusable AI service layer when connecting from API routes

    line 58

≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
coding-standards.mdc
---
description: 
globs: 
alwaysApply: true
---
# Coding Standards

This document outlines coding standards and best practices for the AI Backends project.

## TypeScript Usage

- Use proper TypeScript types and avoid `any` when possible
- Create interfaces for complex data structures
- Use type guards when necessary for type narrowing
- Leverage TypeScript's utility types (Pick, Omit, Partial, etc.)

## API Design

- Follow RESTful principles for resource-based endpoints
- Use consistent naming conventions for endpoints
- Document APIs using OpenAPI/Swagger via Hono's built-in support
- Return appropriate HTTP status codes
- Implement proper error handling and validation
- Routes should be in the src/routes folder and named with dash-separated lowercase words

## Error Handling

- Use consistent error handling patterns
- Provide meaningful error messages
- Create custom error classes when appropriate
- Log errors with sufficient context for debugging
- Don't expose sensitive information in error messages

## Performance Considerations

- Avoid blocking operations when possible
- Use caching where appropriate
- Consider rate limiting for resource-intensive operations
- Implement pagination for large data sets
- Implement exponential backoff for all external API calls to avoid hitting rate limits

## Security Best Practices

- Sanitize and validate all user input
- Store sensitive information in environment variables
- Implement proper authentication and authorization
- Follow the principle of least privilege
- Keep dependencies updated

## AI Integration

- Handle AI model responses appropriately
- Set reasonable timeouts for AI model calls
- Implement fallbacks for when AI services are unavailable
- Consider streaming responses for long-running AI operations
- Validate AI output before returning to clients
- Implement exponential backoff for all external API calls to avoid hitting rate limits
- Use the reusable AI service layer when connecting from API routes

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.