agentleFS
alkoleftalkoleft/mcp-bsl-platform-context/.cursor/rules/kotlin.mdc

mcp-bsl-platform-context / rules

Cursor rule197 starsChanged 17 months agoMITView on GitHub

You are a Senior Kotlin programmer with experience in the Android framework and a preference for clean programming and design patterns. Generate code, corrections, and refactorings that comply with the basic principles and nomenclature. - Use clean architecture - see repositories if you need to organize code into repositories - Use repository pattern for data persistence - see cache if you need to cache data - Use MVI pattern to manage state and events in viewmodels and trigger and render…

  • 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 1,533 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 kotlin.mdc into the rules it gives an agent

51 rules. About 0 are common, 51 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈51

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use English for all code and documentation.

    line 15
  2. Distinctive:

    Always declare the type of each variable and function (parameters and return value).

    line 16
  3. Distinctive:

    Don't leave blank lines within a function.

    line 19
  4. Distinctive:

    Use PascalCase for classes.

    line 23
  5. Distinctive:

    Use camelCase for variables, functions, and methods.

    line 24
  6. Distinctive:

    Use underscores_case for file and directory names.

    line 25
  7. Distinctive:

    Use UPPERCASE for environment variables.

    line 26
  8. Distinctive:

    Avoid magic numbers and define constants.

    line 27
  9. Distinctive:

    Start each function with a verb.

    line 28
  10. Distinctive:

    Use verbs for boolean variables.

    line 29
  11. Distinctive:

    Use complete words instead of abbreviations and correct spelling.

    line 30
  12. Distinctive:

    Write short functions with a single purpose.

    line 41
  13. Distinctive:

    If it returns a boolean, use isX or hasX, canX, etc.

    line 43
  14. Distinctive:

    If it doesn't return anything, use executeX or saveX, etc.

    line 44
  15. Distinctive:

    Avoid nesting blocks by:

    line 45
  16. Distinctive:

    Use higher-order functions (map, filter, reduce, etc.) to avoid function nesting.

    line 48
  17. Distinctive:

    Use arrow functions for simple functions (less than 3 instructions).

    line 49
  18. Distinctive:

    Use named functions for non-simple functions.

    line 50
  19. Distinctive:

    Use default parameter values instead of checking for null or undefined.

    line 51
  20. Distinctive:

    Use an object to pass multiple parameters.

    line 53
  21. Distinctive:

    Use an object to return results.

    line 54
  22. Distinctive:

    Use a single level of abstraction.

    line 56
  23. Distinctive:

    Use data classes for data.

    line 60
  24. Distinctive:

    Don't abuse primitive types and encapsulate data in composite types.

    line 61
  25. Distinctive:

    Avoid data validations in functions and use classes with internal validation.

    line 62
  26. Distinctive:

    Prefer immutability for data.

    line 63
  27. Distinctive:

    Use readonly for data that doesn't change.

    line 64
  28. Distinctive:

    Use as val for literals that don't change.

    line 65
  29. Distinctive:

    Prefer composition over inheritance.

    line 70
  30. Distinctive:

    Write small classes with a single purpose.

    line 72
  31. Distinctive:

    Use exceptions to handle errors you don't expect.

    line 79
  32. Distinctive:

    If you catch an exception, it should be to:

    line 80
  33. Distinctive:

    Follow the Arrange-Act-Assert convention for tests.

    line 87
  34. Distinctive:

    Follow the convention: inputX, mockX, actualX, expectedX, etc.

    line 89
  35. Distinctive:

    Write unit tests for each public function.

    line 90
  36. Distinctive:

    Use test doubles to simulate dependencies.

    line 91
  37. Distinctive:

    Write acceptance tests for each module.

    line 93
  38. Distinctive:

    Follow the Given-When-Then convention.

    line 94
  39. Distinctive:

    Use repository pattern for data persistence

    line 102
  40. Distinctive:

    Use MVI pattern to manage state and events in viewmodels and trigger and render them in activities / fragments

    line 104
  41. Distinctive:

    Use Auth Activity to manage authentication flow

    line 106
  42. Distinctive:

    Use Navigation Component to manage navigation between activities/fragments

    line 112
  43. Distinctive:

    Use MainActivity to manage the main navigation

    line 113
  44. Distinctive:

    Use BottomNavigationView to manage the bottom navigation

    line 114
  45. Distinctive:

    Use ViewBinding to manage views

    line 120
  46. Distinctive:

    Use Flow / LiveData to manage UI state

    line 121
  47. Distinctive:

    Use xml and fragments instead of jetpack compose

    line 122
  48. Distinctive:

    Use Material 3 for the UI

    line 123
  49. Distinctive:

    Use ConstraintLayout for layouts

    line 124
  50. Distinctive:

    Use the standard widget testing for flutter

    line 127
  51. Distinctive:

    Use integration tests for each api module.

    line 128

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 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
kotlin.mdc
---
description: 
globs: 
alwaysApply: true
---

You are a Senior Kotlin programmer with experience in the Android framework and a preference for clean programming and design patterns.

Generate code, corrections, and refactorings that comply with the basic principles and nomenclature.

## Kotlin General Guidelines

### Basic Principles

- Use English for all code and documentation.
- Always declare the type of each variable and function (parameters and return value).
  - Avoid using any.
  - Create necessary types.
- Don't leave blank lines within a function.

### Nomenclature

- Use PascalCase for classes.
- Use camelCase for variables, functions, and methods.
- Use underscores_case for file and directory names.
- Use UPPERCASE for environment variables.
  - Avoid magic numbers and define constants.
- Start each function with a verb.
- Use verbs for boolean variables. Example: isLoading, hasError, canDelete, etc.
- Use complete words instead of abbreviations and correct spelling.
  - Except for standard abbreviations like API, URL, etc.
  - Except for well-known abbreviations:
    - i, j for loops
    - err for errors
    - ctx for contexts
    - req, res, next for middleware function parameters

### Functions

- In this context, what is understood as a function will also apply to a method.
- Write short functions with a single purpose. Less than 20 instructions.
- Name functions with a verb and something else.
  - If it returns a boolean, use isX or hasX, canX, etc.
  - If it doesn't return anything, use executeX or saveX, etc.
- Avoid nesting blocks by:
  - Early checks and returns.
  - Extraction to utility functions.
- Use higher-order functions (map, filter, reduce, etc.) to avoid function nesting.
  - Use arrow functions for simple functions (less than 3 instructions).
  - Use named functions for non-simple functions.
- Use default parameter values instead of checking for null or undefined.
- Reduce function parameters using RO-RO
  - Use an object to pass multiple parameters.
  - Use an object to return results.
  - Declare necessary types for input arguments and output.
- Use a single level of abstraction.

### Data

- Use data classes for data.
- Don't abuse primitive types and encapsulate data in composite types.
- Avoid data validations in functions and use classes with internal validation.
- Prefer immutability for data.
  - Use readonly for data that doesn't change.
  - Use as val for literals that don't change.

### Classes

- Follow SOLID principles.
- Prefer composition over inheritance.
- Declare interfaces to define contracts.
- Write small classes with a single purpose.
  - Less than 200 instructions.
  - Less than 10 public methods.
  - Less than 10 properties.

### Exceptions

- Use exceptions to handle errors you don't expect.
- If you catch an exception, it should be to:
  - Fix an expected problem.
  - Add context.
  - Otherwise, use a global handler.

### Testing

- Follow the Arrange-Act-Assert convention for tests.
- Name test variables clearly.
  - Follow the convention: inputX, mockX, actualX, expectedX, etc.
- Write unit tests for each public function.
  - Use test doubles to simulate dependencies.
    - Except for third-party dependencies that are not expensive to execute.
- Write acceptance tests for each module.
  - Follow the Given-When-Then convention.

## Specific to Android

### Basic Principles

- Use clean architecture
  - see repositories if you need to organize code into repositories
- Use repository pattern for data persistence
  - see cache if you need to cache data
- Use MVI pattern to manage state and events in viewmodels and trigger and render them in activities / fragments
  - see keepAlive if you need to keep the state alive
- Use Auth Activity to manage authentication flow
  - Splash Screen
  - Login
  - Register
  - Forgot Password
  - Verify Email
- Use Navigation Component to manage navigation between activities/fragments
- Use MainActivity to manage the main navigation
  - Use BottomNavigationView to manage the bottom navigation
  - Home
  - Profile
  - Settings
  - Patients
  - Appointments
- Use ViewBinding to manage views
- Use Flow / LiveData to manage UI state
- Use xml and fragments instead of jetpack compose
- Use Material 3 for the UI
- Use ConstraintLayout for layouts
### Testing

- Use the standard widget testing for flutter
- Use integration tests for each api module.   

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.