Last active
May 8, 2026 14:35
-
-
Save chutch3/9ee89b6b2d797a0e78adeb4b0dd1c604 to your computer and use it in GitHub Desktop.
A prompt I use to make help keep my development consistent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Development Context & Guidelines | |
| **Pre-flight:** Review `.plan` documents for context. If execution is ambiguous, ask for clarification before proceeding. Do not force solutions. | |
| ## 1. General Principles & Architecture | |
| - **Discipline:** Strictly follow Red/Green/Refactor. Bug fixes begin with a failing test. | |
| - **Outside-In TDD:** Start with a failing integration test to define the contract (inputs/outputs). Iterate with unit tests. When unit tests pass, the integration test must pass. | |
| - **YAGNI & Simple Design:** Build only what is required now. Remove unneeded complexity. | |
| - **12-Factor App & XP:** Enforce stateless processes, environment-based config, explicit dependencies, disposable execution, and continuous refactoring. | |
| - **The Circle Architecture (Seams & Boundaries):** | |
| - *Inner Ring:* Core logic you own. Fully unit tested. | |
| - *Outer Ring:* 3rd-party libs, system calls, external services. Covered by integration/e2e tests. | |
| - *Mocking Rule:* NEVER mock 3rd-party/system dependencies directly. Encapsulate them behind an abstraction you own, and mock that abstraction. | |
| - **Testing:** Assertions must be strong (return structure, types, values, boundary interactions). Make dependencies injectable at every seam. | |
| ## 2. C# / .NET | |
| - **Structure:** Group by component type (e.g., `Controllers/`, `Daos/`). Place interfaces in corresponding subfolders (e.g., `Controllers/Interfaces/ISomeController.cs`). | |
| - **Dependency Injection:** Define interfaces for all dependencies to enforce contracts and enable mocking. | |
| - **Clean Program.cs:** Register services via static layer extension methods (e.g., `ApplicationServiceCollectionExtensions`). Call these in `Program.cs`. | |
| - **Lifetimes:** `AddTransient` (stateless), `AddScoped` (request-scoped, DbContext), `AddSingleton` (shared state). Prevent captive dependencies. | |
| - **Testing Structure:** | |
| - *1:1 Mapping:* Module to Test Project (`MyApp.Core` -> `MyApp.Core.Tests`). | |
| - *Mirrored Paths:* Test namespaces/folders must identically match source code. | |
| - *Separation:* Unit tests (fast, isolated, mocked) in the primary test project. Integration tests (DBs, APIs) in a separate project (e.g., `MyApp.IntegrationTests`). | |
| ## 3. Python / Object-Oriented | |
| - **Implementation:** 100% type annotations. Imports at the top. Do not test pure data models (pydantic, dataclasses) unless they contain custom business logic. | |
| - **Test Structure:** Mirror subjects (Test classes for classes; standalone test functions for functions). | |
| - **Fixtures:** Scope pytest fixtures correctly. Use a `subject` fixture for the class under test. Apply DI overrides inside the `subject` fixture. | |
| - **Mocking Strategy:** | |
| - Always use `spec=SomeClass` to prevent silent attribute/method spoofing. | |
| - Do not manually override methods with `AsyncMock` if `spec` handles it. | |
| - Limit `unittest.mock.patch` to unavoidable global state (e.g., `os.environ`). | |
| - Use `mock.assert_called_*` to validate boundary integrations. | |
| ## 4. Bash / Scripting / BATS | |
| - **Script Authorship:** | |
| - Shebang: `#!/usr/bin/env bash` | |
| - Safety: `set -euo pipefail` | |
| - Hygiene: Quote all `$vars`. Use `[[ ]]` for conditionals. Use `$(...)` instead of backticks. Declare `local` variables and `readonly` constants. | |
| - Execution: Route errors to `stderr` (`>&2`). Use meaningful exit codes. Use `trap` and `mktemp` for cleanup. Never parse `ls`. Scripts must be idempotent. | |
| - **BATS Testing:** | |
| - Structure: 1 BATS file per script. Use `setup`/`teardown`. | |
| - Execution: Use `run` to capture output/codes. Assert using `bats-assert` helpers. | |
| - Mocking: Stub external commands (curl, aws, docker) by creating scripts in a temp `bin/` directory and prepending to `$PATH`. | |
| - Integration: Keep tests invoking real external tools separate, gated behind CI flags/env vars. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment