|
| 1 | +--- |
| 2 | +alwaysApply: true |
| 3 | +description: Ensure every new feature supports both CLI and YAML ApplyDocument, and clearly distinguishes INFRA vs non-INFRA commands. |
| 4 | +--- |
| 5 | + |
| 6 | +# Feature Interface Consistency (CLI + YAML ApplyDocument) |
| 7 | + |
| 8 | +When introducing any new user-facing feature, always provide both: |
| 9 | + |
| 10 | +- CLI interface with appropriate subcommands and flags |
| 11 | +- YAML ApplyDocument support via a dedicated YAML kind (create one if it does not exist) |
| 12 | + |
| 13 | +This policy prevents drift between interfaces and guarantees first-class automation support. |
| 14 | + |
| 15 | +## Command taxonomy: INFRA vs other commands |
| 16 | + |
| 17 | +- INFRA-related functionality belongs under `cmd/infra` (e.g., plan/apply/diff/show/validate flows) |
| 18 | + - Keep business logic in the `internal/apply` pipeline and `internal/services/*` layers |
| 19 | + - Ensure operations are surfaced in: `apply`, `plan`, `diff`, `show`, `validate` |
| 20 | + |
| 21 | +- Non-INFRA functionality belongs in its domain-specific command group: |
| 22 | + - `cmd/atlas/*` for Atlas resources and account/project/cluster/user/network surfaces |
| 23 | + - `cmd/database/*` for MongoDB database-level operations |
| 24 | + - `cmd/config/*` for CLI configuration and credentials |
| 25 | + |
| 26 | +Both paths must call the same service-layer code in `internal/services/*` to avoid divergence. |
| 27 | + |
| 28 | +## CLI requirements |
| 29 | + |
| 30 | +- Add or extend a subcommand in the correct command group (`cmd/infra`, `cmd/atlas`, `cmd/database`, `cmd/config`) |
| 31 | +- Provide flags that are consistent with existing naming and patterns |
| 32 | +- Validate inputs and route requests through shared services in `internal/services/*` |
| 33 | +- Update command help and autocompletion if applicable |
| 34 | + |
| 35 | +Relevant entry points and patterns: |
| 36 | +- `cmd/infra/*.go` |
| 37 | +- `cmd/atlas/**/*.go` |
| 38 | +- `cmd/database/**/*.go` |
| 39 | +- `internal/services/*` |
| 40 | + |
| 41 | +## YAML (ApplyDocument) requirements |
| 42 | + |
| 43 | +- If a unique YAML kind already exists for the object, ensure ApplyDocument supports the new fields/behaviors. |
| 44 | +- If no unique YAML kind exists, create one and implement end-to-end support: |
| 45 | + - Define or extend types in: [internal/types/apply.go](mdc:internal/types/apply.go), [internal/types/*.go](mdc:internal/types) |
| 46 | + - Load and map kinds in: [internal/apply/loader.go](mdc:internal/apply/loader.go) |
| 47 | + - Validate schema and semantics in: [internal/apply/validation.go](mdc:internal/apply/validation.go), [internal/validation/schema.go](mdc:internal/validation/schema.go) |
| 48 | + - Wire execution to services in: [internal/apply/executor.go](mdc:internal/apply/executor.go), [internal/apply/fetchers.go](mdc:internal/apply/fetchers.go) |
| 49 | + - Keep diff/dry-run output coherent in: [internal/apply/diff_formatter.go](mdc:internal/apply/diff_formatter.go), [internal/apply/dryrun_formatter.go](mdc:internal/apply/dryrun_formatter.go) |
| 50 | + |
| 51 | +Both CLI and YAML paths must use the same service-layer implementations in `internal/services/*` (e.g., [internal/services/atlas](mdc:internal/services/atlas), [internal/services/database](mdc:internal/services/database)). |
| 52 | + |
| 53 | +## Documentation and examples |
| 54 | + |
| 55 | +- Add a minimal YAML example to `examples/` and reference it from `docs/` |
| 56 | +- Update relevant docs pages under `docs/` to describe the CLI flags and YAML kind usage |
| 57 | + |
| 58 | +## Per-feature tracking |
| 59 | + |
| 60 | +To ensure clarity and traceability, every feature MUST include a concise per-feature summary file: |
| 61 | + |
| 62 | +- Location: `features/` |
| 63 | +- Template: `features/TEMPLATE.md` |
| 64 | +- Naming: `YYYY-MM-DD-<short-slug>.md` (e.g., `2025-08-13-temporary-users.md`) or `FTR-<id>-<short-slug>.md` |
| 65 | +- Minimum content: a top-level title (`Feature: <name>`) and a short "Summary" (2–6 sentences) |
| 66 | +- Recommended content: sections mapping changes across CLI, YAML ApplyDocument, service layer, apply pipeline, types, tests, docs, and any breaking/migration notes |
| 67 | + |
| 68 | +## Acceptance checklist (must have) |
| 69 | + |
| 70 | +- CLI subcommand/flags added in the correct command group |
| 71 | +- YAML kind exists and is supported by ApplyDocument end-to-end |
| 72 | +- Both interfaces call the same `internal/services/*` logic |
| 73 | +- Docs updated and example YAML added |
| 74 | + - Per-feature tracking file added under `features/` using the template, with a filled Summary and links to relevant code/docs |
| 75 | + |
0 commit comments