Kotlin Springboot Best Practices (.cursorrules)
# Kotlin Coding Best Practices for Spring Boot Development ## Project Structure and Organization 1. Group your source code into clearly defi...
Structured JSON Schema
Use with automated API pipelines, LangChain, or custom image generators
{
"prompt": "# Kotlin Coding Best Practices for Spring Boot Development ## Project Structure and Organization 1. Group your source code into clearly defined packages like controller, service, repository, and model to separate concerns and improve maintainability. 2. Organize your file system so that each directory mirrors the Kotlin package name (e.g. put under src/main/kotlin/com/myapp/users). 3. Name each Kotlin file after the primary class or concept it contains to make the codebase easier to navigate and understand. 4. Avoid vague file names like ; instead, use concise and meaningful names that reflect the purpose of the file’s contents. 5. Place your Spring Boot application entry point in the root package and structure sub-packages by layer or feature to help Spring scan and organize components efficiently. ## Coding Style and Conventions 1. Use PascalCase for class and object names, camelCase for functions and variables, and UPPER_SNAKE_CASE for constants to 2. Declare variables using `val` by default, and only use `var` when mutation is necessary to promote safer, more predictable code. ```kotlin val maxConnections = 10 // immutable reference var currentUsers = 0 // mutable, try to avoid if possible ``` 3. Limit the scope of variables to where they are actually used—inside functions or smaller blocks—to avoid accidental misuse and make code easier to follow. 4. Format your code consistently using 4-space indentation, proper spacing around operators and commas, and short, focused functions to improve clarity and maintainability. 5. Write clear and expressive code instead of clever one-liners; break complex logic into intermediate variables or well-named functions to improve readability. 6. Name classes, functions, and variables descriptively to convey intent, and avoid vague suffixes like '-Manager' or '-Helper' that don’t add meaning. 7. Keep property getters and setters simple and free of heavy logic; if complex behavior is needed, move it into a separate method to keep property access predictable. ## Idiomatic Kotlin Usage 1. Use data class to define DTOs and entities so you get useful methods like `equals()` and `copy()` without writing boilerplate code. 2. Replace overloaded constructors with default and named parameters to simplify function calls and make them more expressive. ```kotlin // Kotlin – use default parameters fun createConnection(host: String, secure: Boolean = true) { … } createConnection(\"\") // uses default secure=true createConnection(host = \"\", secure = false) // named arg for clarity ``` 3. Use `when` expressions instead of long `if-else` chains to write cleaner, more readable conditional logic that clearly handles each case. 4. Create extension functions instead of utility classes to add reusable behavior to existing types in a more natural and readable way. ```kotlin fun lizeFirst(): String = replaceFirstChar { aseChar() } println(\"kotlin\".capitalizeFirst()) // prints \"Kotlin\" ``` 5. Use scope functions like `apply`, `let`, `also`, `run`, and `with` to reduce repetition and clearly express object configuration or null-safe operations. 6. Declare variables as nullable only when necessary, and handle them using safe-call operators (`?.`) and the Elvis operator (`?:`) to avoid runtime crashes. 7. Avoid us",
"model": "Claude 3.7 Sonnet / Cursor",
"aspect_ratio": "1:1",
"category": "Coding Agents",
"content_type": "coding_prompt",
"surface": "agents_hub",
"quality_score": 82,
"provenance": "SYSTEM_RULE"
}
Voice Search & FAQs
Natural voice queries and direct answers for Siri, Google Assistant & Perplexity
"What is the best Coding Agents prompt for Claude 3.7 Sonnet / Cursor?"
The Kotlin Springboot Best Practices (.cursorrules) blueprint is optimized for Claude 3.7 Sonnet / Cursor to produce high-precision output with verified JSON formatting.
"How do I prompt Claude 3.7 Sonnet / Cursor for Kotlin Springboot Best Practices (.cursorrules)?"
Use the verified Kotlin Springboot Best Practices (.cursorrules) prompt from JsonPrompts.in. Copy the prompt or structured JSON blueprint and paste it directly into Claude 3.7 Sonnet / Cursor.
"Where can I find free Claude 3.7 Sonnet / Cursor prompt templates for Coding Agents?"
JsonPrompts.in offers free verified Coding Agents JSON prompt blueprints including Kotlin Springboot Best Practices (.cursorrules), with zero sign-up required.