A comprehensive ruleset guiding the LLM to produce robust, maintainable, and clean object-oriented code and architectural advice.
Rule:
Always follow the SOLID principles in OOP designs and code examples:
Description:
Enforces writing clean, maintainable, and flexible object-oriented code.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Never duplicate logic or code. Encourage refactoring to reusable functions, classes, or modules whenever repeated patterns are detected.
Description:
Promotes maintainability and reduces bugs caused by duplicate logic.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Encapsulate class fields and internal logic. Expose only necessary APIs. Avoid public mutable fields unless justified.
Description:
Protects internal state and reduces unintended side effects.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Prefer composing objects to adding unnecessary inheritance hierarchies. Recommend using interfaces or protocols to define behavior when possible.
Description:
Reduces tight coupling and promotes flexible architecture.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Encourage defining contracts via interfaces or abstract classes instead of using concrete classes directly.
Description:
Improves flexibility and testability of code.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Maintain a single level of abstraction within methods and classes. Avoid mixing high-level and low-level operations in the same function.
Description:
Keeps code easy to read and maintain.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Keep methods small (generally under 20-30 lines). If a method grows large, refactor it into smaller helper methods.
Description:
Improves readability and reduces cognitive load.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Use clear, meaningful names for classes, methods, variables, and interfaces. Avoid ambiguous short names unless context is clear (e.g., i
in a loop).
Description:
Improves readability and maintainability.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Encourage writing code that is easily testable, with dependencies injected via interfaces or constructors, and minimal static or global state.
Description:
Improves code quality and long-term stability.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Recommend applying appropriate design patterns for solving common architectural or design problems. When suggesting a pattern, include:
Supported Patterns Include:
Description:
Empowers developers to solve problems with proven solutions.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Encourage clean architecture principles:
Description:
Promotes long-term maintainability and flexibility.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Favor immutable objects where feasible, especially for data transfer objects and value objects. Use read-only properties and immutable collections where supported.
Description:
Prevents accidental state mutation and simplifies reasoning about code.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Discourage creating large classes or services that handle unrelated responsibilities. Recommend breaking them into smaller classes aligned with single responsibilities.
Description:
Prevents high complexity and promotes separation of concerns.
Globs:
*.ts
*.js
*.java
*.cs
Rule:
Whenever suggesting public classes, methods, or interfaces, generate concise documentation comments (e.g. JSDoc, TSDoc, JavaDoc) describing purpose, parameters, and return values.
Description:
Improves code understanding and collaboration.
Globs:
*.ts
*.js
*.java
*.cs