mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-04-22 22:26:38 +00:00
47 lines
6.8 KiB
Plaintext
47 lines
6.8 KiB
Plaintext
---
|
|
description: "Enforces readable, environment-aware coding standards with scope discipline, meaningful comments, and test verification"
|
|
alwaysApply: true
|
|
---
|
|
# Coding preferences
|
|
- Prefer the simplest solution that satisfies all requirements, including maintainability. When in doubt between two approaches, choose the one with fewer moving parts — but never sacrifice correctness, error handling, or readability for brevity.
|
|
- Follow the Single Responsibility Principle — a class or method should have one reason to change:
|
|
- If a method is hard to name precisely from the caller's perspective, its responsibility is misplaced. Vague names like "candidate", "data", or "item" are a signal — fix the design, not just the name.
|
|
- Logic specific to a platform, variant, or environment belongs in the class that owns that variant, not in the general coordinator. Passing a dependency through is preferable to leaking variant-specific concepts into shared code.
|
|
- Only use static methods for pure, self-contained computations (constants, simple math, stateless lookups). If a static method involves resource access, side effects, OS interaction, or logic that varies across subclasses or environments — use an instance method or factory class instead. Before implementing a non-trivial static method, ask the user.
|
|
- Avoid boilerplate and unnecessary indirection, but never sacrifice readability for brevity.
|
|
- Never suppress errors silently — no `2>/dev/null`, empty `catch` blocks, bare `except: pass`, or discarded error returns. These hide the information you need most when something breaks. If an error is truly safe to ignore, log it or comment why.
|
|
- Do not add comments that merely narrate what the code does. Comments are appropriate for: non-obvious business rules, workarounds with references to issues/bugs, safety invariants, and public API contracts. Make comments as short and concise as possible. Exception: every test must use the Arrange / Act / Assert pattern with language-appropriate comment syntax (`# Arrange` for Python, `// Arrange` for C#/Rust/JS/TS). Omit any section that is not needed (e.g. if there is no setup, skip Arrange; if act and assert are the same line, keep only Assert)
|
|
- Do not add verbose debug/trace logs by default. Log exceptions, security events (auth failures, permission denials), and business-critical state transitions. Add debug-level logging only when asked.
|
|
- Do not put code annotations unless it was asked specifically
|
|
- Write code that takes into account the different environments: development, production
|
|
- You are careful to make changes that are requested or you are confident the changes are well understood and related to the change being requested
|
|
- Mocking data is needed only for tests, never mock data for dev or prod env
|
|
- Make test environment (files, db and so on) as close as possible to the production environment
|
|
- When you add new libraries or dependencies make sure you are using the same version of it as other parts of the code
|
|
- When writing code that calls a library API, verify the API actually exists in the pinned version. Check the library's changelog or migration guide for breaking changes between major versions. Never assume an API works at a given version — test the actual call path before committing.
|
|
- When a test fails due to a missing dependency, install it — do not fake or stub the module system. For normal packages, add them to the project's dependency file (requirements-test.txt, package.json devDependencies, test csproj, etc.) and install. Only consider stubbing if the dependency is heavy (e.g. hardware-specific SDK, large native toolchain) — and even then, ask the user first before choosing to stub.
|
|
- Do not solve environment or infrastructure problems (dependency resolution, import paths, service discovery, connection config) by hardcoding workarounds in source code. Fix them at the environment/configuration level.
|
|
- Before writing new infrastructure or workaround code, check how the existing codebase already handles the same concern. Follow established project patterns.
|
|
- If a file, class, or function has no remaining usages — delete it. Dead code rots: its dependencies drift, it misleads readers, and it breaks when the code it depends on evolves. However, before deletion verify that the symbol is not used via any of the following. If any applies, do NOT delete — leave it or ASK the user:
|
|
- Public API surface exported from the package and potentially consumed outside the workspace (see `workspace-boundary.mdc`)
|
|
- Reflection, dependency injection, or service registration (scan DI container registrations, `appsettings.json` / equivalent config, attribute-based discovery, plugin manifests)
|
|
- Dynamic dispatch from config/data (YAML/JSON references, string-based class lookups, route tables, command dispatchers)
|
|
- Test fixtures used only by currently-skipped tests — temporary skips may become active again
|
|
- Cross-repo references — if this workspace is part of a multi-repo system, grep sibling repos for shared contracts before deleting
|
|
|
|
- **Scope discipline**: focus edits on the task scope. The "scope" is:
|
|
- Files the task explicitly names
|
|
- Files that define interfaces the task changes
|
|
- Files that directly call, implement, or test the changed code
|
|
- **Adjacent hygiene is permitted** without asking: fixing imports you caused to break, updating obvious stale references within a file you already modify, deleting code that became dead because of your change.
|
|
- **Unrelated issues elsewhere**: do not silently fix them as part of this task. Either note them to the user at end of turn and ASK before expanding scope, or record in `_docs/_process_leftovers/` for later handling.
|
|
- Always think about what other methods and areas of code might be affected by the code changes, and surface the list to the user before modifying.
|
|
- When you think you are done with changes, run the full test suite. Every failure in tests that cover code you modified or that depend on code you modified is a **blocking gate**. For pre-existing failures in unrelated areas, report them to the user but do not block on them. Never silently ignore or skip a failure without reporting it. On any blocking failure, stop and ask the user to choose one of:
|
|
- **Investigate and fix** the failing test or source code
|
|
- **Remove the test** if it is obsolete or no longer relevant
|
|
- Do not rename any databases or tables or table columns without confirmation. Avoid such renaming if possible.
|
|
|
|
- Make sure we don't commit binaries, create and keep .gitignore up to date and delete binaries after you are done with the task
|
|
- Never force-push to main or dev branches
|
|
- For new projects, place source code under `src/` (this works for all stacks including .NET). For existing projects, follow the established directory structure. Keep project-level config, tests, and tooling at the repo root.
|