Skip to content

feat: Add git root discovery for default base path#1773

Merged
aknysh merged 9 commits intomainfrom
git-root-discovery
Nov 10, 2025
Merged

feat: Add git root discovery for default base path#1773
aknysh merged 9 commits intomainfrom
git-root-discovery

Conversation

@osterman
Copy link
Member

@osterman osterman commented Nov 9, 2025

Summary

  • Enables running Atmos from any subdirectory like Git automatically discovers repository root
  • Local configuration always takes precedence over git root discovery
  • Feature controlled by ATMOS_GIT_ROOT_BASEPATH environment variable

Test Plan

  • All unit tests passing (18 new test cases in git_root_basepath_test.go)
  • Existing CLI tests passing with ATMOS_GIT_ROOT_BASEPATH=false set
  • Build successful with make build
  • Code follows architectural patterns and linting rules

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Automatic Git repository root discovery: Atmos can run from subdirectories and use the repo root as the base path.
  • Behavior

    • Local config files/directories in the current directory take precedence; discovery applies only when no local config is present.
    • Discovery can be disabled via an environment variable for tests or opt-out.
  • Documentation

    • New docs and blog post with examples, rollout guidance, and migration notes.
  • Tests

    • Added tests covering discovery, local-config detection, env override, and edge cases.
  • Other

    • Additional trace logs to aid debugging and rollout validation.

Enable running Atmos from any subdirectory like Git. When using the default
embedded configuration and no local Atmos config exists, Atmos now
automatically discovers the git repository root and uses it as the base path.

Local configuration always takes precedence—if atmos.yaml, .atmos.yaml,
.atmos/, .atmos.d/, or atmos.d/ exist in the current directory, git root
discovery is skipped.

This behavior is controlled by ATMOS_GIT_ROOT_BASEPATH environment variable
(defaults to enabled, set to "false" to disable for testing).

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

Co-Authored-By: Claude <noreply@anthropic.com>
@osterman osterman requested a review from a team as a code owner November 9, 2025 04:54
@github-actions github-actions bot added the size/xl Extra large size PR label Nov 9, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 9, 2025

📝 Walkthrough

Walkthrough

Adds post-config-load git-repository-root-based resolution for Atmos' BasePath (opt-out via ATMOS_GIT_ROOT_BASEPATH). Implements local-config detection, tests for precedence and env overrides, updates tests/snapshots and docs, introduces detection constants, bumps two dependencies, and logs (non-fatal) discovery failures during LoadConfig.

Changes

Cohort / File(s) Summary
Design & Spec
docs/prd/git-root-discovery-default-behavior.md
New PRD describing problem, options, recommended approach (post-process BasePath), rollout/migration plan, tests, metrics, and open questions.
Config Constants
pkg/config/const.go
Adds public constants for local config detection: AtmosConfigFileName, DotAtmosConfigFileName, AtmosConfigDirName, AtmosDefaultImportsDirName, DotAtmosDefaultImportsDirName.
Config Logic
pkg/config/git_root.go, pkg/config/load.go
Implements applyGitRootBasePath() and hasLocalAtmosConfig(); LoadConfig invokes applyGitRootBasePath after loading and preserves previous behavior on error; gating via ATMOS_GIT_ROOT_BASEPATH, local-config presence, default flags, and BasePath state.
Config Tests
pkg/config/git_root_basepath_test.go
New table-driven tests covering local-config detection, env-var disable, default vs non-default configs, empty BasePath cases, and TEST_GIT_ROOT-driven happy path. Uses temporary dirs and testify.
Test Suite Updates & Snapshots
tests/cli_test.go, tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
Tests explicitly disable git-root discovery via ATMOS_GIT_ROOT_BASEPATH=false; snapshot updated to include new trace log entries.
Documentation & Blog
website/blog/2025-11-08-git-root-discovery.md, website/docs/cli/configuration/configuration.mdx
New blog post and docs section explaining git-root discovery behavior, local-config precedence, examples, and the ATMOS_GIT_ROOT_BASEPATH opt-out.
Deps & Notices
go.mod, NOTICE
Bumped dependencies: azcore v1.19.1 → v1.20.0 and hdrhistogram-go v1.1.2 → v1.2.0; NOTICE updated license URLs accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LoadConfig
    participant hasLocalConfig
    participant GitResolver
    participant Result

    User->>LoadConfig: LoadConfig()
    activate LoadConfig

    Note over LoadConfig: After parsing config, preserve identity then attempt git-root base_path post-processing

    LoadConfig->>hasLocalConfig: hasLocalAtmosConfig(CWD)
    activate hasLocalConfig
    hasLocalConfig-->>LoadConfig: true/false
    deactivate hasLocalConfig

    alt ATMOS_GIT_ROOT_BASEPATH == "false" or local config found or non-default BasePath
        LoadConfig-->>Result: Skip git-root base_path change
    else
        LoadConfig->>GitResolver: ProcessTagGitRoot("!repo-root .")
        activate GitResolver
        GitResolver-->>LoadConfig: gitRootPath / error
        deactivate GitResolver

        alt git root found
            LoadConfig->>Result: set BasePath = gitRootPath
        else
            LoadConfig-->>Result: keep BasePath as "."
        end
    end

    LoadConfig-->>User: return config (errors logged but not fatal)
    deactivate LoadConfig
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas to check closely:
    • Conditional gates in applyGitRootBasePath (env var, local-config detection, default config flag, BasePath semantics).
    • Accuracy and false-positive risk of hasLocalAtmosConfig file/directory checks.
    • Test isolation and environment handling (TEST_GIT_ROOT, ATMOS_GIT_ROOT_BASEPATH) and updated snapshot expectations.
    • Non-fatal error handling/logging in LoadConfig when git discovery fails.

Possibly related PRs

Suggested reviewers

  • milldr
  • kevcube

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% 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 title clearly describes the main feature: git root discovery for determining the default base path. It accurately reflects the primary change across the changeset.
✨ 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 git-root-discovery

📜 Recent 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 daf9eec and b3e3ddc.

📒 Files selected for processing (1)
  • pkg/config/git_root.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/config/git_root.go
⏰ 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 (macos)
  • GitHub Check: Build (linux)
  • GitHub Check: Build (windows)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: autofix
  • GitHub Check: Review Dependency Licenses
  • GitHub Check: website-deploy-preview
  • GitHub Check: Summary

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.

@mergify
Copy link

mergify bot commented Nov 9, 2025

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
Copy link

github-actions bot commented Nov 9, 2025

Dependency Review

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

OpenSSF Scorecard

PackageVersionScoreDetails
gomod/github.com/Azure/azure-sdk-for-go/sdk/azcore 1.20.0 🟢 7.2
Details
CheckScoreReason
Code-Review🟢 10all changesets reviewed
Packaging⚠️ -1packaging workflow not detected
Maintained🟢 1030 commit(s) and 11 issue activity found in the last 90 days -- score normalized to 10
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions🟢 9detected GitHub workflow tokens with excessive permissions
Security-Policy🟢 10security policy file detected
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
Fuzzing⚠️ 0project is not fuzzed
Binary-Artifacts🟢 10no binaries found in the repo
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Vulnerabilities🟢 91 existing vulnerabilities detected
gomod/github.com/HdrHistogram/hdrhistogram-go 1.2.0 🟢 5
Details
CheckScoreReason
Maintained🟢 34 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3
Packaging⚠️ -1packaging workflow not detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Code-Review🟢 10all changesets reviewed
Binary-Artifacts🟢 9binaries present in source code
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Security-Policy⚠️ 0security policy file not detected
License🟢 10license file detected
Fuzzing⚠️ 0project is not fuzzed
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Signed-Releases⚠️ -1no releases found
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Vulnerabilities🟢 100 existing vulnerabilities detected
SAST🟢 7SAST tool detected but not run on all commits

Scanned Files

  • go.mod

@osterman osterman added the minor New features that do not break anything label Nov 9, 2025
Add comprehensive documentation for the git root discovery feature in the
CLI Configuration page. Explains how it works, when it activates, local
configuration precedence, and how to disable it.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Updates the Valid_Log_Level_in_Config_File test snapshot to include new
TRACE-level log messages that were introduced by the git root discovery
feature. The snapshot now correctly captures the "Git root base path
disabled via ATMOS_GIT_ROOT_BASEPATH=false" trace messages.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Nov 9, 2025

Codecov Report

❌ Patch coverage is 81.39535% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.67%. Comparing base (bc06ba6) to head (b3e3ddc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/config/git_root.go 85.36% 4 Missing and 2 partials ⚠️
pkg/config/load.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1773      +/-   ##
==========================================
+ Coverage   70.61%   70.67%   +0.05%     
==========================================
  Files         429      430       +1     
  Lines       39664    39707      +43     
==========================================
+ Hits        28010    28064      +54     
+ Misses       9270     9256      -14     
- Partials     2384     2387       +3     
Flag Coverage Δ
unittests 70.67% <81.39%> (+0.05%) ⬆️

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

Files with missing lines Coverage Δ
pkg/config/load.go 79.45% <0.00%> (-0.44%) ⬇️
pkg/config/git_root.go 85.36% <85.36%> (ø)

... 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
tests/cli_test.go (1)

809-812: Let test cases override ATMOS_GIT_ROOT_BASEPATH.
We hardwire the env var to "false" here, so even if a YAML test case wants to exercise the git-root behavior it cannot opt in. Please guard the assignment (e.g., only set it when the map lacks a value) so feature-specific tests stay possible.

website/docs/cli/configuration/configuration.mdx (1)

232-275: Add ATMOS_GIT_ROOT_BASEPATH to the environment variables table for discoverability.

The git root discovery feature is well-documented here, but the ATMOS_GIT_ROOT_BASEPATH environment variable mentioned in the disable section should also be listed in the environment variables reference table (around lines 1001–1043) so users can discover it easily.

Suggested addition to the environment variables table:

| ATMOS_GIT_ROOT_BASEPATH                           | N/A                                             | Enable/disable automatic git root discovery. When set to "false", uses current directory as base path instead. Defaults to enabled when using default embedded config with no local Atmos configuration present |
website/blog/2025-11-08-git-root-discovery.md (1)

73-81: Use smart quotes for consistency with standard publishing.

The final paragraph (line 82 in static analysis) contains straight quotes that could be replaced with smart/curly quotes ("" and '') for a more polished appearance, consistent with modern technical blogging standards.

-Just like Git changed your mental model from "I must be at the root" to "I can work anywhere," Atmos now does the same for infrastructure orchestration.
+Just like Git changed your mental model from "I must be at the root" to "I can work anywhere," Atmos now does the same for infrastructure orchestration.
docs/prd/git-root-discovery-default-behavior.md (1)

1-1286: Address markdown linting standards for consistency with repository.

Static analysis flags several markdown formatting issues:

  • Lines with emphasis used instead of proper headings (MD036): Lines 117, 122, 127, 132, 137, 144, 148, 152, 156, 496, 620, 1251, 1256, 1261, 1266, 1271
  • Fenced code blocks missing language specification (MD040): Lines 164, 1201
  • Various typographic quote style suggestions

While the content is excellent, aligning with the repository's markdown standards will ensure consistency. Consider:

  1. Converting **Bold text for headings** patterns to proper markdown headings (e.g., ### Heading)
  2. Adding language identifiers to all code fences (e.g., ```go instead of ` ````)
  3. Using smart/curly quotes where appropriate

These are largely style improvements that won't affect technical accuracy.

📜 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 bc06ba6 and 25f4230.

📒 Files selected for processing (8)
  • docs/prd/git-root-discovery-default-behavior.md (1 hunks)
  • pkg/config/const.go (1 hunks)
  • pkg/config/git_root_basepath_test.go (1 hunks)
  • pkg/config/load.go (3 hunks)
  • tests/cli_test.go (1 hunks)
  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden (1 hunks)
  • website/blog/2025-11-08-git-root-discovery.md (1 hunks)
  • website/docs/cli/configuration/configuration.mdx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
website/**

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

website/**: Update website documentation in website/ when adding features
Ensure consistency between CLI help text and website documentation
Follow the website's documentation structure and style
Keep website code in website/ and follow its architecture/style; test changes locally
Keep CLI and website documentation in sync; document new features with examples and use cases

Files:

  • website/docs/cli/configuration/configuration.mdx
  • website/blog/2025-11-08-git-root-discovery.md
pkg/**/*.go

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

Place business logic in pkg rather than in cmd

Files:

  • pkg/config/const.go
  • pkg/config/git_root_basepath_test.go
  • pkg/config/load.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/config/const.go
  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
  • pkg/config/load.go
**/!(*_test).go

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

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

Files:

  • pkg/config/const.go
  • pkg/config/load.go
**/*_test.go

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

**/*_test.go: Every new feature must include comprehensive unit tests
Test both happy paths and error conditions
Use table-driven tests for multiple scenarios

Files:

  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
🧠 Learnings (44)
📓 Common learnings
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: Final XDG Base Directory Specification implementation for atmos toolchain is complete and verified: toolchain/xdg_cache.go provides GetXDGCacheDir() and GetXDGTempCacheDir() functions, all hardcoded ~/.cache/tools-cache paths have been replaced with XDG-compliant paths using ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback), and tests have been updated to expect the new path structure.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: XDG Base Directory Specification compliance implementation for atmos toolchain is complete: created toolchain/xdg_cache.go with GetXDGCacheDir() and GetXDGTempCacheDir() functions, updated toolchain/installer.go and cmd/toolchain_clean.go to use these XDG helpers, and changed all cache paths from hardcoded ~/.cache/tools-cache to XDG-compliant ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback).
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: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain XDG compliance implementation is complete with GetXDGCacheDir() and GetXDGTempCacheDir() functions in toolchain/xdg_cache.go, updated installer.go and toolchain_clean.go to use these helpers, and changed cache paths from ~/.cache/tools-cache to ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain when XDG_CACHE_HOME is not set).
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain has been updated to follow XDG Base Directory Specification with helper functions GetXDGCacheDir() and GetXDGTempCacheDir() in toolchain/xdg_cache.go, using XDG_CACHE_HOME when set and falling back to ~/.cache/atmos-toolchain, making it consistent with atmos core's XDG compliance.
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.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1697
File: internal/exec/oci_utils.go:0-0
Timestamp: 2025-11-08T19:56:18.647Z
Learning: In the Atmos codebase, when a function receives an `*schema.AtmosConfiguration` parameter, it should read configuration values from `atmosConfig.Settings` fields rather than using direct `os.Getenv()` or `viper.GetString()` calls. The Atmos pattern is: viper.BindEnv in cmd/root.go binds environment variables → Viper unmarshals into atmosConfig.Settings via mapstructure → business logic reads from the Settings struct. This provides centralized config management, respects precedence, and enables testability. Example: `atmosConfig.Settings.AtmosGithubToken` instead of `os.Getenv("ATMOS_GITHUB_TOKEN")` in functions like `getGHCRAuth` in internal/exec/oci_utils.go.
Learnt from: Benbentwo
Repo: cloudposse/atmos PR: 1475
File: pkg/auth/providers/github/oidc.go:96-100
Timestamp: 2025-09-10T17:34:52.568Z
Learning: The ATMOS_ environment variable binding guideline applies to Atmos configuration variables, not external service-required environment variables like GitHub Actions OIDC variables (GITHUB_ACTIONS, ACTIONS_ID_TOKEN_*) which must use their standard names.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain should follow XDG Base Directory Specification like the rest of atmos core, using XDG_CACHE_HOME environment variable when available and falling back to ~/.cache when not set, instead of hardcoding ~/.cache/tools-cache paths.
Learnt from: Listener430
Repo: cloudposse/atmos PR: 912
File: pkg/config/config.go:91-92
Timestamp: 2025-01-09T19:53:29.847Z
Learning: In the Atmos project, the `core.inject_github_token` configuration is required to be enabled (`true`) by default to support authenticated GitHub requests and help bypass rate limits.
Learnt from: osterman
Repo: cloudposse/atmos PR: 0
File: :0-0
Timestamp: 2025-02-04T22:45:15.845Z
Learning: URL validation in Atmos should support query parameters (like `depth=1` and `ref=`) which are commonly used in Git URLs for shallow clones and version references.
Learnt from: osterman
Repo: cloudposse/atmos PR: 899
File: examples/tests/vendor.yaml:48-48
Timestamp: 2025-01-08T19:02:28.099Z
Learning: Test cases in the Atmos project deliberately use different Git URL formats (with and without `git::` prefix) to test various scenarios. These formats should not be normalized to maintain test coverage of different URL handling cases.
📚 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:

  • website/docs/cli/configuration/configuration.mdx
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain has been updated to follow XDG Base Directory Specification with helper functions GetXDGCacheDir() and GetXDGTempCacheDir() in toolchain/xdg_cache.go, using XDG_CACHE_HOME when set and falling back to ~/.cache/atmos-toolchain, making it consistent with atmos core's XDG compliance.

Applied to files:

  • website/docs/cli/configuration/configuration.mdx
  • website/blog/2025-11-08-git-root-discovery.md
  • pkg/config/const.go
  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
  • pkg/config/load.go
📚 Learning: 2024-10-23T22:11:41.077Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 727
File: internal/exec/path_utils.go:145-146
Timestamp: 2024-10-23T22:11:41.077Z
Learning: In the `atmos` project, the preference is to print relative paths in log messages instead of full paths.

Applied to files:

  • website/docs/cli/configuration/configuration.mdx
  • website/blog/2025-11-08-git-root-discovery.md
  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
📚 Learning: 2025-01-25T15:21:40.413Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: examples/demo-atmos-cli-imports/atmos.yaml:8-8
Timestamp: 2025-01-25T15:21:40.413Z
Learning: In Atmos, when a directory is specified for configuration loading (e.g., in the `import` section of atmos.yaml), all files within that directory should be treated as Atmos configurations. Do not suggest restricting file extensions in directory-based glob patterns.

Applied to files:

  • website/docs/cli/configuration/configuration.mdx
  • docs/prd/git-root-discovery-default-behavior.md
📚 Learning: 2025-01-08T19:02:28.099Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 899
File: examples/tests/vendor.yaml:48-48
Timestamp: 2025-01-08T19:02:28.099Z
Learning: Test cases in the Atmos project deliberately use different Git URL formats (with and without `git::` prefix) to test various scenarios. These formats should not be normalized to maintain test coverage of different URL handling cases.

Applied to files:

  • website/docs/cli/configuration/configuration.mdx
📚 Learning: 2024-11-19T14:50:16.194Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 768
File: internal/exec/vendor_utils.go:496-513
Timestamp: 2024-11-19T14:50:16.194Z
Learning: In the Atmos project, path traversal is acceptable due to its role in automation. Do not flag path traversal as an issue in code reviews.

Applied to files:

  • website/docs/cli/configuration/configuration.mdx
📚 Learning: 2024-12-11T18:40:12.808Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 844
File: cmd/helmfile.go:37-37
Timestamp: 2024-12-11T18:40:12.808Z
Learning: In the atmos project, `cliConfig` is initialized within the `cmd` package in `root.go` and can be used in other command files.

Applied to files:

  • website/docs/cli/configuration/configuration.mdx
  • pkg/config/const.go
  • tests/cli_test.go
  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
  • pkg/config/load.go
📚 Learning: 2025-11-08T19:56:18.647Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1697
File: internal/exec/oci_utils.go:0-0
Timestamp: 2025-11-08T19:56:18.647Z
Learning: In the Atmos codebase, when a function receives an `*schema.AtmosConfiguration` parameter, it should read configuration values from `atmosConfig.Settings` fields rather than using direct `os.Getenv()` or `viper.GetString()` calls. The Atmos pattern is: viper.BindEnv in cmd/root.go binds environment variables → Viper unmarshals into atmosConfig.Settings via mapstructure → business logic reads from the Settings struct. This provides centralized config management, respects precedence, and enables testability. Example: `atmosConfig.Settings.AtmosGithubToken` instead of `os.Getenv("ATMOS_GITHUB_TOKEN")` in functions like `getGHCRAuth` in internal/exec/oci_utils.go.

Applied to files:

  • website/docs/cli/configuration/configuration.mdx
  • website/blog/2025-11-08-git-root-discovery.md
  • pkg/config/const.go
  • pkg/config/git_root_basepath_test.go
  • docs/prd/git-root-discovery-default-behavior.md
  • pkg/config/load.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: Final XDG Base Directory Specification implementation for atmos toolchain is complete and verified: toolchain/xdg_cache.go provides GetXDGCacheDir() and GetXDGTempCacheDir() functions, all hardcoded ~/.cache/tools-cache paths have been replaced with XDG-compliant paths using ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback), and tests have been updated to expect the new path structure.

Applied to files:

  • website/docs/cli/configuration/configuration.mdx
  • pkg/config/git_root_basepath_test.go
  • docs/prd/git-root-discovery-default-behavior.md
  • tests/cli_test.go
  • pkg/config/load.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/config/const.go
  • pkg/config/git_root_basepath_test.go
  • docs/prd/git-root-discovery-default-behavior.md
  • tests/cli_test.go
  • pkg/config/load.go
📚 Learning: 2024-10-20T13:12:46.499Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 736
File: pkg/config/const.go:6-6
Timestamp: 2024-10-20T13:12:46.499Z
Learning: In `cmd/cmd_utils.go`, it's acceptable to have hardcoded references to `atmos.yaml` in logs, and it's not necessary to update them to use the `CliConfigFileName` constant.

Applied to files:

  • pkg/config/const.go
  • pkg/config/load.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/config/const.go
  • pkg/config/git_root_basepath_test.go
  • docs/prd/git-root-discovery-default-behavior.md
  • pkg/config/load.go
📚 Learning: 2025-07-05T20:59:02.914Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1363
File: internal/exec/template_utils.go:18-18
Timestamp: 2025-07-05T20:59:02.914Z
Learning: In the Atmos project, gomplate v4 is imported with a blank import (`_ "github.com/hairyhenderson/gomplate/v4"`) alongside v3 imports to resolve AWS SDK version conflicts. V3 uses older AWS SDK versions that conflict with newer AWS modules used by Atmos. A full migration to v4 requires extensive refactoring due to API changes and should be handled in a separate PR.

Applied to files:

  • pkg/config/const.go
  • pkg/config/load.go
📚 Learning: 2024-12-12T15:17:45.245Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: examples/demo-atmos.d/atmos.d/tools/helmfile.yml:10-10
Timestamp: 2024-12-12T15:17:45.245Z
Learning: In `examples/demo-atmos.d/atmos.d/tools/helmfile.yml`, when suggesting changes to `kubeconfig_path`, ensure that the values use valid Go template syntax.

Applied to files:

  • pkg/config/const.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain XDG compliance implementation is complete with GetXDGCacheDir() and GetXDGTempCacheDir() functions in toolchain/xdg_cache.go, updated installer.go and toolchain_clean.go to use these helpers, and changed cache paths from ~/.cache/tools-cache to ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain when XDG_CACHE_HOME is not set).

Applied to files:

  • pkg/config/const.go
  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
  • pkg/config/load.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: XDG Base Directory Specification compliance implementation for atmos toolchain is complete: created toolchain/xdg_cache.go with GetXDGCacheDir() and GetXDGTempCacheDir() functions, updated toolchain/installer.go and cmd/toolchain_clean.go to use these XDG helpers, and changed all cache paths from hardcoded ~/.cache/tools-cache to XDG-compliant ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback).

Applied to files:

  • pkg/config/const.go
  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
  • pkg/config/load.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/config/const.go
📚 Learning: 2025-08-29T20:57:35.423Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1433
File: cmd/theme_list.go:33-36
Timestamp: 2025-08-29T20:57:35.423Z
Learning: In the Atmos codebase, avoid using viper.SetEnvPrefix("ATMOS") with viper.AutomaticEnv() because canonical environment variable names are not exclusive to Atmos and could cause conflicts. Instead, use selective environment variable binding through the setEnv function in pkg/config/load.go with bindEnv(v, "config.key", "ENV_VAR_NAME") for specific environment variables.

Applied to files:

  • pkg/config/const.go
  • pkg/config/load.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 Viper for configuration management; support files, env vars, and flags with precedence flags > env > config > defaults

Applied to files:

  • pkg/config/const.go
📚 Learning: 2025-04-23T15:02:50.246Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1202
File: pkg/utils/yaml_func_exec.go:104-104
Timestamp: 2025-04-23T15:02:50.246Z
Learning: In the Atmos codebase, direct calls to `os.Getenv` should be avoided. Instead, use `viper.BindEnv` for environment variable access. This provides a consistent approach to configuration management across the codebase.

Applied to files:

  • pkg/config/const.go
📚 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:

  • pkg/config/const.go
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: The atmos codebase has a custom extension to *testing.T that provides a Chdir method, allowing test functions to call t.Chdir() to change working directories during tests. This is used consistently across test files in the codebase.

Applied to files:

  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
  • pkg/config/load.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 **/*_test.go : Test both happy paths and error conditions

Applied to files:

  • pkg/config/git_root_basepath_test.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 **/*_test.go : Every new feature must include comprehensive unit tests

Applied to files:

  • pkg/config/git_root_basepath_test.go
📚 Learning: 2024-10-28T01:51:30.811Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:329-332
Timestamp: 2024-10-28T01:51:30.811Z
Learning: In the Atmos Go code, when deleting directories or handling file paths (e.g., in `terraform_clean.go`), always resolve the absolute path using `filepath.Abs` and use the logger `u.LogWarning` for logging messages instead of using `fmt.Printf`.

Applied to files:

  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
  • pkg/config/load.go
📚 Learning: 2025-08-15T14:43:41.030Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1352
File: pkg/store/artifactory_store_test.go:108-113
Timestamp: 2025-08-15T14:43:41.030Z
Learning: In test files for the atmos project, it's acceptable to ignore errors from os.Setenv/Unsetenv operations during test environment setup and teardown, as these are controlled test scenarios.

Applied to files:

  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: In the atmos codebase, t.Chdir() is a valid method call on *testing.T objects and works correctly for changing directories in tests. This is implemented through custom testing framework extensions and is used consistently throughout the test suite.

Applied to files:

  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: In the atmos codebase, t.Chdir() is a valid method call on *testing.T objects and works correctly for changing directories in tests.

Applied to files:

  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
📚 Learning: 2025-05-23T19:51:47.091Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1255
File: cmd/describe_affected_test.go:15-15
Timestamp: 2025-05-23T19:51:47.091Z
Learning: In the atmos codebase, t.Chdir() is a valid method that can be called on *testing.T objects. This functionality is implemented through custom testing framework extensions and is used consistently throughout the test suite for changing working directories during tests.

Applied to files:

  • pkg/config/git_root_basepath_test.go
  • tests/cli_test.go
📚 Learning: 2025-01-25T03:51:57.689Z
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.

Applied to files:

  • docs/prd/git-root-discovery-default-behavior.md
📚 Learning: 2024-11-22T12:38:33.132Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 768
File: internal/exec/vendor_utils.go:496-513
Timestamp: 2024-11-22T12:38:33.132Z
Learning: In the Atmos project, continue to flag path traversal issues in code reviews but acknowledge when they are expected and acceptable in specific cases.

Applied to files:

  • docs/prd/git-root-discovery-default-behavior.md
📚 Learning: 2024-12-13T15:28:13.630Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 844
File: cmd/version.go:34-44
Timestamp: 2024-12-13T15:28:13.630Z
Learning: In `cmd/version.go`, when handling the `--check` flag in the `versionCmd`, avoid using `CheckForAtmosUpdateAndPrintMessage(cliConfig)` as it updates the cache timestamp, which may not be desired in this context.

Applied to files:

  • tests/cli_test.go
📚 Learning: 2025-02-06T13:38:07.216Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 984
File: internal/exec/copy_glob.go:0-0
Timestamp: 2025-02-06T13:38:07.216Z
Learning: The `u.LogTrace` function in the `cloudposse/atmos` repository accepts `atmosConfig` as its first parameter, followed by the message string.

Applied to files:

  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
  • pkg/config/load.go
📚 Learning: 2025-02-24T22:46:39.744Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 1085
File: pkg/config/load.go:219-221
Timestamp: 2025-02-24T22:46:39.744Z
Learning: In the Atmos configuration system, imports from atmos.d are optional. When import errors occur, they should be logged at debug level and the process should continue, rather than failing completely.

Applied to files:

  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
📚 Learning: 2025-01-16T11:41:35.531Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 942
File: internal/exec/describe_affected_utils.go:802-807
Timestamp: 2025-01-16T11:41:35.531Z
Learning: When checking if a component is enabled in Atmos, use standardized helper function that includes logging. The function should check the `enabled` field in the component's metadata section and log a trace message when skipping disabled components.

Applied to files:

  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
📚 Learning: 2025-11-09T19:06:58.447Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1752
File: pkg/profile/list/formatter_table.go:27-29
Timestamp: 2025-11-09T19:06:58.447Z
Learning: In the cloudposse/atmos repository, performance tracking with `defer perf.Track()` is enforced on all functions via linting, including high-frequency utility functions, formatters, and renderers. This is a repository-wide policy to maintain consistency and avoid making case-by-case judgment calls about which functions should have profiling.

Applied to files:

  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
  • pkg/config/load.go
📚 Learning: 2025-03-17T18:41:08.831Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 1085
File: pkg/config/imports.go:68-75
Timestamp: 2025-03-17T18:41:08.831Z
Learning: In the Atmos configuration import system, errors during config file merging are logged at debug level and the process continues with other imports rather than failing completely, prioritizing resilience over strict correctness.

Applied to files:

  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
📚 Learning: 2025-11-05T05:07:58.125Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1746
File: pkg/flags/global_flags.go:69-81
Timestamp: 2025-11-05T05:07:58.125Z
Learning: In the Atmos project, the default log level should be "Warning", not "Info". Info-level logging is considered too noisy for default behavior. The project philosophy is to use the UI for user-facing output and reserve logging for actual diagnostic logs, discouraging developers from using Info logs as a UI mechanism.

Applied to files:

  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
📚 Learning: 2025-02-03T05:57:18.407Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 959
File: cmd/cmd_utils.go:121-148
Timestamp: 2025-02-03T05:57:18.407Z
Learning: The Atmos CLI should fail fast (exit) when encountering configuration errors, including command alias configuration issues, to prevent undefined behavior. Use LogErrorAndExit instead of returning errors in such cases.

Applied to files:

  • tests/snapshots/TestCLICommands_Valid_Log_Level_in_Config_File.stderr.golden
📚 Learning: 2025-09-13T18:06:07.674Z
Learnt from: samtholiya
Repo: cloudposse/atmos PR: 1466
File: toolchain/list.go:39-42
Timestamp: 2025-09-13T18:06:07.674Z
Learning: In the cloudposse/atmos repository, for UI messages in the toolchain package, use utils.PrintfMessageToTUI instead of log.Error or fmt.Fprintln(os.Stderr, ...). Import pkg/utils with alias "u" to follow the established pattern.

Applied to files:

  • pkg/config/load.go
📚 Learning: 2025-05-30T03:21:37.197Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1274
File: go.mod:63-63
Timestamp: 2025-05-30T03:21:37.197Z
Learning: The redis dependency (github.com/redis/go-redis/v9) in the atmos project is only used in tests, not in production code.

Applied to files:

  • pkg/config/load.go
📚 Learning: 2025-08-16T23:32:40.412Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1405
File: internal/exec/describe_dependents_test.go:455-456
Timestamp: 2025-08-16T23:32:40.412Z
Learning: In the cloudposse/atmos Go codebase, `InitCliConfig` returns a `schema.AtmosConfiguration` value (not a pointer), while `ExecuteDescribeDependents` expects a `*schema.AtmosConfiguration` pointer parameter. Therefore, when passing the result of `InitCliConfig` to `ExecuteDescribeDependents`, use `&atmosConfig` to pass the address of the value.

Applied to files:

  • pkg/config/load.go
📚 Learning: 2025-08-16T23:33:07.477Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1405
File: internal/exec/describe_dependents_test.go:651-652
Timestamp: 2025-08-16T23:33:07.477Z
Learning: In the cloudposse/atmos Go codebase, ExecuteDescribeDependents expects a pointer to AtmosConfiguration (*schema.AtmosConfiguration), so when calling it with a value returned by cfg.InitCliConfig (which returns schema.AtmosConfiguration), the address-of operator (&) is necessary: ExecuteDescribeDependents(&atmosConfig, ...).

Applied to files:

  • pkg/config/load.go
🧬 Code graph analysis (2)
pkg/config/git_root_basepath_test.go (1)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/config/load.go (3)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/utils/git.go (1)
  • ProcessTagGitRoot (16-67)
pkg/config/const.go (5)
  • AtmosConfigFileName (12-12)
  • DotAtmosConfigFileName (13-13)
  • AtmosConfigDirName (16-16)
  • DotAtmosDefaultImportsDirName (18-18)
  • AtmosDefaultImportsDirName (17-17)
🪛 LanguageTool
website/blog/2025-11-08-git-root-discovery.md

[typographical] ~82-~82: Consider using a typographic opening quote here.
Context: ...like Git changed your mental model from "I must be at the root" to "I can work an...

(EN_QUOTES)


[typographical] ~82-~82: Consider using a typographic close quote here.
Context: ...mental model from "I must be at the root" to "I can work anywhere," Atmos now doe...

(EN_QUOTES)


[typographical] ~82-~82: Consider using a typographic opening quote here.
Context: ...l model from "I must be at the root" to "I can work anywhere," Atmos now does the...

(EN_QUOTES)


[typographical] ~82-~82: Consider using a typographic close quote here.
Context: ...be at the root" to "I can work anywhere," Atmos now does the same for infrastruct...

(EN_QUOTES)

docs/prd/git-root-discovery-default-behavior.md

[typographical] ~56-~56: Consider using a typographic close quote here.
Context: ...oke - base path pointed to non-existent "!repo-root" directory #### Attempt 2: ...

(EN_QUOTES)


[style] ~78-~78: Since ownership is already implied, this phrasing may be redundant.
Context: ...still needed base_path: !repo-root in their own config - Added complexity without deliv...

(PRP_OWN)


[typographical] ~108-~108: Consider using a typographic opening quote here.
Context: ... tests break:** - Tests rely on default BasePath: "." from defaultCliConfig (line 23 of ...

(EN_QUOTES)


[typographical] ~125-~125: Consider using a typographic opening quote here.
Context: ...uld see no change - Users with explicit base_path: "." in their config must be respected *...

(EN_QUOTES)


[typographical] ~133-~133: Consider using typographic quotation marks here.
Context: ...nfiguration** - Default behavior should "just work" for new users - No configuration requir...

(EN_QUOTES)


[typographical] ~240-~240: Consider using a typographic opening quote here.
Context: ...✅ Respects user configuration (explicit base_path: "." honored) - ✅ Clear separation of con...

(EN_QUOTES)


[grammar] ~368-~368: Please add a punctuation mark at the end of paragraph.
Context: ... - ❌ Hides important behavior in getter method ### Option 5: Default to Git Root in d...

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~426-~426: Consider using typographic quotation marks here.
Context: ...discover and enable feature - ❌ Defeats "zero configuration" goal ### Option 7: Auto-Chdir to Git R...

(EN_QUOTES)


[typographical] ~478-~478: Consider using a typographic opening quote here.
Context: ...g finds atmos.yaml at root 5. Default BasePath: "." now resolves to git root 6. Everythi...

(EN_QUOTES)


[typographical] ~485-~485: Consider using typographic quotation marks here.
Context: ...solve from git root - ✅ Config search "just works" - Finds atmos.yaml at root automati...

(EN_QUOTES)


[typographical] ~486-~486: Consider using a typographic opening quote here.
Context: ...lly - ✅ No config changes - Default BasePath: "." is perfect - ✅ **Simple implementati...

(EN_QUOTES)


[typographical] ~493-~493: In American English, use a period after an abbreviation.
Context: ... - ❌ Can't distinguish - User's pwd vs Atmos's internal working dir - ❌ **Test...

(MISSING_PERIOD_AFTER_ABBREVIATION)


[grammar] ~494-~494: Please add a punctuation mark at the end of paragraph.
Context: ... - Need to restore directory after each test Critical issue: User expectations ...

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~508-~508: Consider using a typographic opening quote here.
Context: ...chdir` flag is explicit - user says "change to this directory". Auto-chdir is...

(EN_QUOTES)


[typographical] ~508-~508: Consider using a typographic close quote here.
Context: ...** - user says "change to this directory". Auto-chdir is implicit - surprisin...

(EN_QUOTES)


[typographical] ~591-~591: Consider using a typographic opening quote here.
Context: ...guration indicators (any of these means "local config exists"):** - atmos.yaml ...

(EN_QUOTES)


[typographical] ~591-~591: Consider using a typographic close quote here.
Context: ...(any of these means "local config exists"):** - atmos.yaml - Main config file -...

(EN_QUOTES)


[typographical] ~601-~601: Consider using a typographic opening quote here.
Context: ... is true) 3. BasePath is default value (".") 4. ATMOS_GIT_ROOT_BASEPATH is not ...

(EN_QUOTES)


[typographical] ~601-~601: Consider using a typographic close quote here.
Context: ...s true) 3. BasePath is default value (".") 4. ATMOS_GIT_ROOT_BASEPATH is not se...

(EN_QUOTES)


[typographical] ~602-~602: Consider using typographic quotation marks here.
Context: ...ATMOS_GIT_ROOT_BASEPATH is not set to "false" 5. Currently in a git repository **Pro...

(EN_QUOTES)


[grammar] ~603-~603: Please add a punctuation mark at the end of paragraph.
Context: ...ot set to "false" 5. Currently in a git repository Pros: - Simpler implementation (~5...

(PUNCTUATION_PARAGRAPH_END)


[style] ~638-~638: ‘by mistake’ might be wordy. Consider a shorter alternative.
Context: ...rs who put atmos.yaml in subdirectory by mistake - Matches user mental model better - **...

(EN_WORDINESS_PREMIUM_BY_MISTAKE)


[typographical] ~646-~646: Consider using typographic quotation marks here.
Context: ...t (integration tests needed) - May find "wrong" config file if multiple exist ### Why ...

(EN_QUOTES)


[typographical] ~648-~648: Consider using a typographic opening quote here.
Context: ...fig file if multiple exist ### Why the "No Local Config" Constraint is Critical ...

(EN_QUOTES)


[typographical] ~648-~648: Consider using a typographic close quote here.
Context: ...iple exist ### Why the "No Local Config" Constraint is Critical **Problem witho...

(EN_QUOTES)


[typographical] ~691-~691: Consider using a typographic opening quote here.
Context: ...root 5. Matches user expectations - "If I'm in a directory with atmos.yaml,...

(EN_QUOTES)


[typographical] ~691-~691: Consider using a typographic close quote here.
Context: ... a directory with atmos.yaml, use that" Behavior matrix: | Location | Has...

(EN_QUOTES)


[typographical] ~704-~704: Consider using a typographic opening quote here.
Context: ....as base path (fallback) | **Note:** "Has Atmos Config" means ANY of:atmos.y...

(EN_QUOTES)


[typographical] ~704-~704: Consider using a typographic close quote here.
Context: ...fallback) | Note: "Has Atmos Config" means ANY of: atmos.yaml, `.atmos.yam...

(EN_QUOTES)


[typographical] ~1088-~1088: Consider using a typographic opening quote here.
Context: ...rk 2. Current directory users - Add base_path: "." to atmos.yaml to preserve behavior...

(EN_QUOTES)


[grammar] ~1142-~1142: Please add a punctuation mark at the end of paragraph.
Context: ...d in atmosConfig.BasePath for command duration ### Risk 4: Windows Compatibility **P...

(PUNCTUATION_PARAGRAPH_END)


[typographical] ~1165-~1165: Consider using a typographic opening quote here.
Context: ...sTagGitRoot()has graceful fallback to "." - No errors if.git` not found - Sea...

(EN_QUOTES)


[typographical] ~1165-~1165: Consider using a typographic close quote here.
Context: ...agGitRoot()has graceful fallback to "." - No errors if.git` not found - Seaml...

(EN_QUOTES)

🪛 markdownlint-cli2 (0.18.1)
docs/prd/git-root-discovery-default-behavior.md

117-117: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


122-122: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


127-127: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


132-132: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


137-137: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


144-144: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


148-148: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


152-152: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


156-156: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


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

(MD040, fenced-code-language)


496-496: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


620-620: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


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

(MD040, fenced-code-language)


1251-1251: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1256-1256: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1261-1261: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1266-1266: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


1271-1271: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

⏰ 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 (windows)
  • GitHub Check: website-deploy-preview
  • GitHub Check: Review Dependency Licenses
  • GitHub Check: Run pre-commit hooks
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: autofix
  • GitHub Check: Summary
🔇 Additional comments (4)
docs/prd/git-root-discovery-default-behavior.md (4)

750-805: Verify ATMOS_GIT_ROOT_BASEPATH binding follows Atmos configuration pattern.

The implementation example (lines 758–805) reads the environment variable directly using os.Getenv(). Based on the Atmos codebase pattern, when a function receives *schema.AtmosConfiguration, configuration values should be read from atmosConfig.Settings fields rather than direct os.Getenv() calls. This provides centralized config management and enables testability.

Confirm whether:

  1. ATMOS_GIT_ROOT_BASEPATH should be bound via viper.BindEnv() in cmd/root.go
  2. The actual implementation reads from atmosConfig.Settings.GitRootBasePath (or similar) instead of os.Getenv()
  3. This is consistent with how other similar flags like ATMOS_GITHUB_TOKEN are handled

This is important to verify in the actual code implementation files (not shown in this review).


649-705: Document the behavior matrix clearly—excellent reference for implementation testing.

Lines 693–704 provide a clear behavior matrix showing all combinations of config location, local config presence, and git repo status. This is excellent for verification testing and should be directly translated into test cases (which the PRD already covers well in lines 932–1054).

Suggest cross-referencing this matrix from the test section to ensure test coverage matches all scenarios:

  • ✓ Repo root with config: use repo config
  • ✓ Repo root without config: use git root as base
  • ✓ Subdirectory with local config: use local (skip git root)
  • ✓ Subdirectory without local config in git repo: use git root
  • ✓ Outside git repo: use current directory

579-648: Clear recommendation with strong rationale for phased approach.

The decision to start with Approach A (post-process BasePath) is well-justified given the lower risk and faster implementation timeline. The critical constraint requiring no local Atmos config to be present is correctly identified as essential for protecting user expectations.

The reasoning at lines 686–691 clearly explains why the "no local config" check prevents silent config overrides—this is exactly the right priority model.


160-208: Architecture overview is precise and identifies the key constraint well.

The analysis at lines 177–208 correctly identifies that embedded config bypasses YAML function processing, which is the fundamental blocker for simpler approaches like base_path: !repo-root in embedded config.

One note: The config search order shown (lines 181–186) should be verified against the actual implementation in pkg/config/load.go to ensure the PRD reflects current behavior. This is worth a quick cross-check during implementation.

aknysh and others added 2 commits November 10, 2025 08:36
Changes:
1. Add happy-path test for git root discovery (addresses CodeRabbitAI feedback)
   - All previous tests had expectChange=false
   - New test uses TEST_GIT_ROOT to verify BasePath updates correctly
   - Ensures regression protection for core feature

2. Extract git root functions to dedicated file (resolve file-length-limit)
   - Move applyGitRootBasePath and hasLocalAtmosConfig to pkg/config/git_root.go
   - Reduces load.go from 836 to 739 lines
   - Remove orphaned comment block for moved function
   - Improves code organization and maintainability

Tests: All pkg/config tests pass

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

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 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 25f4230 and ea516d6.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • go.mod (1 hunks)
  • pkg/config/git_root.go (1 hunks)
  • pkg/config/git_root_basepath_test.go (1 hunks)
  • pkg/config/load.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/config/load.go
  • pkg/config/git_root_basepath_test.go
🧰 Additional context used
📓 Path-based instructions (4)
go.{mod,sum}

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

go.{mod,sum}: Manage dependencies with Go modules
Keep dependencies up to date

Files:

  • go.mod
pkg/**/*.go

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

Place business logic in pkg rather than in cmd

Files:

  • pkg/config/git_root.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/config/git_root.go
**/!(*_test).go

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

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

Files:

  • pkg/config/git_root.go
🧠 Learnings (17)
📓 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: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: Final XDG Base Directory Specification implementation for atmos toolchain is complete and verified: toolchain/xdg_cache.go provides GetXDGCacheDir() and GetXDGTempCacheDir() functions, all hardcoded ~/.cache/tools-cache paths have been replaced with XDG-compliant paths using ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback), and tests have been updated to expect the new path structure.
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.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: XDG Base Directory Specification compliance implementation for atmos toolchain is complete: created toolchain/xdg_cache.go with GetXDGCacheDir() and GetXDGTempCacheDir() functions, updated toolchain/installer.go and cmd/toolchain_clean.go to use these XDG helpers, and changed all cache paths from hardcoded ~/.cache/tools-cache to XDG-compliant ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback).
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain XDG compliance implementation is complete with GetXDGCacheDir() and GetXDGTempCacheDir() functions in toolchain/xdg_cache.go, updated installer.go and toolchain_clean.go to use these helpers, and changed cache paths from ~/.cache/tools-cache to ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain when XDG_CACHE_HOME is not set).
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain has been updated to follow XDG Base Directory Specification with helper functions GetXDGCacheDir() and GetXDGTempCacheDir() in toolchain/xdg_cache.go, using XDG_CACHE_HOME when set and falling back to ~/.cache/atmos-toolchain, making it consistent with atmos core's XDG compliance.
Learnt from: osterman
Repo: cloudposse/atmos PR: 1697
File: internal/exec/oci_utils.go:0-0
Timestamp: 2025-11-08T19:56:18.647Z
Learning: In the Atmos codebase, when a function receives an `*schema.AtmosConfiguration` parameter, it should read configuration values from `atmosConfig.Settings` fields rather than using direct `os.Getenv()` or `viper.GetString()` calls. The Atmos pattern is: viper.BindEnv in cmd/root.go binds environment variables → Viper unmarshals into atmosConfig.Settings via mapstructure → business logic reads from the Settings struct. This provides centralized config management, respects precedence, and enables testability. Example: `atmosConfig.Settings.AtmosGithubToken` instead of `os.Getenv("ATMOS_GITHUB_TOKEN")` in functions like `getGHCRAuth` in internal/exec/oci_utils.go.
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.
Learnt from: osterman
Repo: cloudposse/atmos PR: 808
File: examples/demo-atmos-cli-imports/atmos.yaml:8-8
Timestamp: 2025-01-25T15:21:40.413Z
Learning: In Atmos, when a directory is specified for configuration loading (e.g., in the `import` section of atmos.yaml), all files within that directory should be treated as Atmos configurations. Do not suggest restricting file extensions in directory-based glob patterns.
📚 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 go.{mod,sum} : Keep dependencies up to date

Applied to files:

  • go.mod
📚 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 go.{mod,sum} : Manage dependencies with Go modules

Applied to files:

  • go.mod
📚 Learning: 2025-01-17T00:21:32.987Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 944
File: go.mod:3-3
Timestamp: 2025-01-17T00:21:32.987Z
Learning: Go version 1.23.0 was deliberately introduced by the maintainer (aknysh) in January 2025. While this might be a pre-release or development version of Go, it has been approved for use in this project.

Applied to files:

  • go.mod
📚 Learning: 2025-01-17T00:21:32.987Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 944
File: go.mod:3-3
Timestamp: 2025-01-17T00:21:32.987Z
Learning: The project uses Go version 1.23.0 which has been confirmed by the maintainer to be working in production for months. Do not flag this as an invalid Go version.

Applied to files:

  • go.mod
📚 Learning: 2025-07-05T20:59:02.914Z
Learnt from: aknysh
Repo: cloudposse/atmos PR: 1363
File: internal/exec/template_utils.go:18-18
Timestamp: 2025-07-05T20:59:02.914Z
Learning: In the Atmos project, gomplate v4 is imported with a blank import (`_ "github.com/hairyhenderson/gomplate/v4"`) alongside v3 imports to resolve AWS SDK version conflicts. V3 uses older AWS SDK versions that conflict with newer AWS modules used by Atmos. A full migration to v4 requires extensive refactoring due to API changes and should be handled in a separate PR.

Applied to files:

  • go.mod
  • pkg/config/git_root.go
📚 Learning: 2024-10-28T01:51:30.811Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 727
File: internal/exec/terraform_clean.go:329-332
Timestamp: 2024-10-28T01:51:30.811Z
Learning: In the Atmos Go code, when deleting directories or handling file paths (e.g., in `terraform_clean.go`), always resolve the absolute path using `filepath.Abs` and use the logger `u.LogWarning` for logging messages instead of using `fmt.Printf`.

Applied to files:

  • pkg/config/git_root.go
📚 Learning: 2025-11-08T19:56:18.647Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1697
File: internal/exec/oci_utils.go:0-0
Timestamp: 2025-11-08T19:56:18.647Z
Learning: In the Atmos codebase, when a function receives an `*schema.AtmosConfiguration` parameter, it should read configuration values from `atmosConfig.Settings` fields rather than using direct `os.Getenv()` or `viper.GetString()` calls. The Atmos pattern is: viper.BindEnv in cmd/root.go binds environment variables → Viper unmarshals into atmosConfig.Settings via mapstructure → business logic reads from the Settings struct. This provides centralized config management, respects precedence, and enables testability. Example: `atmosConfig.Settings.AtmosGithubToken` instead of `os.Getenv("ATMOS_GITHUB_TOKEN")` in functions like `getGHCRAuth` in internal/exec/oci_utils.go.

Applied to files:

  • pkg/config/git_root.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/config/git_root.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: XDG Base Directory Specification compliance implementation for atmos toolchain is complete: created toolchain/xdg_cache.go with GetXDGCacheDir() and GetXDGTempCacheDir() functions, updated toolchain/installer.go and cmd/toolchain_clean.go to use these XDG helpers, and changed all cache paths from hardcoded ~/.cache/tools-cache to XDG-compliant ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback).

Applied to files:

  • pkg/config/git_root.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/config/git_root.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: Final XDG Base Directory Specification implementation for atmos toolchain is complete and verified: toolchain/xdg_cache.go provides GetXDGCacheDir() and GetXDGTempCacheDir() functions, all hardcoded ~/.cache/tools-cache paths have been replaced with XDG-compliant paths using ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain fallback), and tests have been updated to expect the new path structure.

Applied to files:

  • pkg/config/git_root.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain has been updated to follow XDG Base Directory Specification with helper functions GetXDGCacheDir() and GetXDGTempCacheDir() in toolchain/xdg_cache.go, using XDG_CACHE_HOME when set and falling back to ~/.cache/atmos-toolchain, making it consistent with atmos core's XDG compliance.

Applied to files:

  • pkg/config/git_root.go
📚 Learning: 2024-12-11T18:40:12.808Z
Learnt from: Listener430
Repo: cloudposse/atmos PR: 844
File: cmd/helmfile.go:37-37
Timestamp: 2024-12-11T18:40:12.808Z
Learning: In the atmos project, `cliConfig` is initialized within the `cmd` package in `root.go` and can be used in other command files.

Applied to files:

  • pkg/config/git_root.go
📚 Learning: 2025-09-08T01:25:44.958Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1466
File: website/docs/cli/commands/toolchain/usage.mdx:117-121
Timestamp: 2025-09-08T01:25:44.958Z
Learning: The atmos toolchain XDG compliance implementation is complete with GetXDGCacheDir() and GetXDGTempCacheDir() functions in toolchain/xdg_cache.go, updated installer.go and toolchain_clean.go to use these helpers, and changed cache paths from ~/.cache/tools-cache to ${XDG_CACHE_HOME}/atmos-toolchain (or ~/.cache/atmos-toolchain when XDG_CACHE_HOME is not set).

Applied to files:

  • pkg/config/git_root.go
📚 Learning: 2025-08-29T20:57:35.423Z
Learnt from: osterman
Repo: cloudposse/atmos PR: 1433
File: cmd/theme_list.go:33-36
Timestamp: 2025-08-29T20:57:35.423Z
Learning: In the Atmos codebase, avoid using viper.SetEnvPrefix("ATMOS") with viper.AutomaticEnv() because canonical environment variable names are not exclusive to Atmos and could cause conflicts. Instead, use selective environment variable binding through the setEnv function in pkg/config/load.go with bindEnv(v, "config.key", "ENV_VAR_NAME") for specific environment variables.

Applied to files:

  • pkg/config/git_root.go
📚 Learning: 2024-10-20T13:12:46.499Z
Learnt from: haitham911
Repo: cloudposse/atmos PR: 736
File: pkg/config/const.go:6-6
Timestamp: 2024-10-20T13:12:46.499Z
Learning: In `cmd/cmd_utils.go`, it's acceptable to have hardcoded references to `atmos.yaml` in logs, and it's not necessary to update them to use the `CliConfigFileName` constant.

Applied to files:

  • pkg/config/git_root.go
🧬 Code graph analysis (1)
pkg/config/git_root.go (5)
pkg/schema/schema.go (1)
  • AtmosConfiguration (27-65)
pkg/logger/log.go (2)
  • Trace (14-16)
  • Debug (24-26)
pkg/logger/global.go (1)
  • Default (19-21)
pkg/utils/git.go (1)
  • ProcessTagGitRoot (16-67)
pkg/config/const.go (5)
  • AtmosConfigFileName (12-12)
  • DotAtmosConfigFileName (13-13)
  • AtmosConfigDirName (16-16)
  • DotAtmosDefaultImportsDirName (18-18)
  • AtmosDefaultImportsDirName (17-17)
⏰ 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). (10)
  • GitHub Check: Build (linux)
  • GitHub Check: Build (macos)
  • GitHub Check: Build (windows)
  • GitHub Check: Run pre-commit hooks
  • GitHub Check: Lint (golangci)
  • GitHub Check: Analyze (go)
  • GitHub Check: autofix
  • GitHub Check: website-deploy-preview
  • GitHub Check: Review Dependency Licenses
  • GitHub Check: Summary
🔇 Additional comments (2)
pkg/config/git_root.go (1)

84-103: LGTM!

The local config detection logic is solid. Properly checks for all Atmos configuration indicators using constants, handles paths correctly with filepath.Join, and logs appropriately.

go.mod (1)

10-10: Dependency updates verified—no security advisories found.

Both updated versions are valid and have no known security vulnerabilities:

  • github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 ✓
  • github.com/HdrHistogram/hdrhistogram-go v1.2.0 ✓

The updates are safe to proceed with.

…T_BASEPATH

Addresses CodeRabbitAI feedback about reading from Settings struct.

The updated comment clarifies:
- This is bootstrap configuration, read during config loading
- Must use os.Getenv() because processEnvVars() runs AFTER LoadConfig()
- Follows same pattern as ATMOS_CLI_CONFIG_PATH in readEnvAmosConfigPath()
- Cannot use Settings struct as it's populated after git root discovery

This is intentional architectural design, not a violation of Atmos patterns.
Bootstrap config (controls config loading) vs application config (loaded from config).

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

Co-Authored-By: Claude <noreply@anthropic.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Nov 10, 2025
@aknysh aknysh merged commit ace63b6 into main Nov 10, 2025
55 checks passed
@aknysh aknysh deleted the git-root-discovery branch November 10, 2025 14:55
@github-actions
Copy link

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

aknysh added a commit that referenced this pull request Dec 15, 2025
The git root discovery feature (added in #1773) causes the repo root's
atmos.yaml configuration to be inherited by examples. This resulted in
the demo-helmfile example inheriting kubeconfig_path: "/dev/shm" from
the repo root, which overwrote the KUBECONFIG env var set by the CI
workflow.

The fix explicitly sets kubeconfig_path: "" in the demo-helmfile's
atmos.yaml to prevent this inheritance, allowing the CI-provided
KUBECONFIG env var to be used.

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

Co-Authored-By: Claude <noreply@anthropic.com>
aknysh added a commit that referenced this pull request Dec 18, 2025
* updates

* updates

* updates

* docs: Add manual testing section for path resolution fix

Added "Manual Testing" section to path-resolution-regression.md with:
- Fixture directory structure explanation
- Step-by-step CLI commands to verify the fix
- Comparison table showing expected vs broken behavior
- Instructions for using ATMOS_CLI_CONFIG_PATH with the test fixture

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

Co-Authored-By: Claude <noreply@anthropic.com>

* updates

* [autofix.ci] apply automated fixes

* fix: Treat single dot (.) as explicit relative path in path resolution

Updated resolveAbsolutePath() to treat a single dot "." as an explicit
relative path that resolves relative to the CLI config directory
(where atmos.yaml is located), rather than resolving to CWD.

This fixes the component-path-resolution tests that use
ATMOS_BASE_PATH="." with ATMOS_CLI_CONFIG_PATH pointing to the repo root.

The path resolution logic now:
1. Absolute paths → return as-is
2. Paths starting with "..", "./" or exactly "." → resolve relative to
   cliConfigPath (atmos.yaml location)
3. Simple paths like "stacks", "components/terraform", empty string →
   resolve relative to CWD (backward compatibility for issue #1858)

This maintains backward compatibility for issue #1858 while also
supporting the path-based component resolution feature.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* add tests

* fix: Tighten explicit relative path detection and make tests platform-neutral

Addresses CodeRabbit review comments:

1. Tighten "explicit relative" path detection:
   - Use exact matches for "." and ".." to avoid misclassifying
     paths like ".hidden" or "..foo" as explicit relative paths
   - Use separator-aware prefix checks (filepath.Separator) for
     "./" and "../" patterns
   - Allow forward slashes on Windows for portability in configs

2. Make absolute path tests platform-neutral:
   - Replace hardcoded Unix paths ("/absolute/path") with paths
     derived from t.TempDir() using filepath.Join()
   - Added test case for "..foo" edge case

3. Updated documentation to reflect the tighter detection logic
   and cross-platform handling.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: Correct version mismatch in TestManager_Rebuild test

The test was setting ATMOS_VERSION to "1.202.0" in the config but
expecting "1.201.0" in the assertion. This was likely an oversight
when the version was bumped - line 412 was updated but line 434
was not.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* address comments, add tests

* fix: Implement correct base path resolution semantics with proper fallback order

- Fix path resolution to treat "." and ".." as config-file-relative (not CWD-relative)
  following the convention of tsconfig.json, package.json, and other config files
- Correct the fallback order: config dir → git root → CWD (last resort)
  Previously CWD was an immediate fallback, now it's only used if git root is unavailable
- Add !cwd YAML function for explicit CWD-relative paths when needed
- Rename test scenarios from issue numbers to behavior descriptions
- Add comprehensive path resolution tests covering edge cases and fallback scenarios
- Update documentation with path resolution semantics table
- Move fixture from issue-1858 → nested-config-empty-base-path (descriptive naming)

Closes #1858

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* docs: Add config file search order to PRD and website docs

Document the atmos.yaml discovery order in both:
- docs/prd/base-path-resolution-semantics.md (FR5)
- website/docs/cli/configuration/configuration.mdx

Search order (highest to lowest priority):
1. CLI flags (--config, --config-path)
2. Environment variable (ATMOS_CLI_CONFIG_PATH)
3. Current directory (./atmos.yaml) - CWD only
4. Git repository root (repo-root/atmos.yaml)
5. Parent directory search
6. Home directory (~/.atmos/atmos.yaml)
7. System directory (/usr/local/etc/atmos/atmos.yaml)

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* fix: Isolate tests from git root discovery

Update tests that use t.Chdir() to fixture directories to set
ATMOS_CLI_CONFIG_PATH, which:
- Isolates tests from the repo's root atmos.yaml
- Disables parent directory search (per pkg/config/load.go)
- Ensures fixtures' atmos.yaml is used, not the repo's

Also adds !cwd to the expected tags list in yaml_utils_test.go
to account for the new YAML function.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Use Trace level for config discovery logs to avoid snapshot failures

Changed log.Debug() calls to log.Trace() for config discovery messages
to prevent them from appearing in test output and causing golden file
mismatches. Added constant for ATMOS_CLI_CONFIG_PATH env var to satisfy
revive linter.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Update golden snapshots for log level change

Updated golden snapshot files to reflect the log level change from
Debug to Trace for config discovery messages:
- Removed "Found config ENV ATMOS_CLI_CONFIG_PATH=..." lines from
  Debug-level test snapshots (now at Trace level)
- Updated Trace-level test snapshots to show "TRCE  Found config ENV..."
  instead of "DEBU  Found config ENV..."
- Added new "TRCE  Found atmos.yaml in current directory" lines to
  Trace-level test snapshots

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Update golden snapshot for atmos_describe_config_imports

Removed "Found config ENV ATMOS_CLI_CONFIG_PATH=..." lines since they're
now at Trace level and won't appear in Debug output.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Correct base path resolution semantics and fallback order (#1872)

* fix: Implement correct base path resolution semantics with proper fallback order

- Fix path resolution to treat "." and ".." as config-file-relative (not CWD-relative)
  following the convention of tsconfig.json, package.json, and other config files
- Correct the fallback order: config dir → git root → CWD (last resort)
  Previously CWD was an immediate fallback, now it's only used if git root is unavailable
- Add !cwd YAML function for explicit CWD-relative paths when needed
- Rename test scenarios from issue numbers to behavior descriptions
- Add comprehensive path resolution tests covering edge cases and fallback scenarios
- Update documentation with path resolution semantics table
- Move fixture from issue-1858 → nested-config-empty-base-path (descriptive naming)

Closes #1858

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* docs: Add config file search order to PRD and website docs

Document the atmos.yaml discovery order in both:
- docs/prd/base-path-resolution-semantics.md (FR5)
- website/docs/cli/configuration/configuration.mdx

Search order (highest to lowest priority):
1. CLI flags (--config, --config-path)
2. Environment variable (ATMOS_CLI_CONFIG_PATH)
3. Current directory (./atmos.yaml) - CWD only
4. Git repository root (repo-root/atmos.yaml)
5. Parent directory search
6. Home directory (~/.atmos/atmos.yaml)
7. System directory (/usr/local/etc/atmos/atmos.yaml)

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* fix: Isolate tests from git root discovery

Update tests that use t.Chdir() to fixture directories to set
ATMOS_CLI_CONFIG_PATH, which:
- Isolates tests from the repo's root atmos.yaml
- Disables parent directory search (per pkg/config/load.go)
- Ensures fixtures' atmos.yaml is used, not the repo's

Also adds !cwd to the expected tags list in yaml_utils_test.go
to account for the new YAML function.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Use Trace level for config discovery logs to avoid snapshot failures

Changed log.Debug() calls to log.Trace() for config discovery messages
to prevent them from appearing in test output and causing golden file
mismatches. Added constant for ATMOS_CLI_CONFIG_PATH env var to satisfy
revive linter.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Update golden snapshots for log level change

Updated golden snapshot files to reflect the log level change from
Debug to Trace for config discovery messages:
- Removed "Found config ENV ATMOS_CLI_CONFIG_PATH=..." lines from
  Debug-level test snapshots (now at Trace level)
- Updated Trace-level test snapshots to show "TRCE  Found config ENV..."
  instead of "DEBU  Found config ENV..."
- Added new "TRCE  Found atmos.yaml in current directory" lines to
  Trace-level test snapshots

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Update golden snapshot for atmos_describe_config_imports

Removed "Found config ENV ATMOS_CLI_CONFIG_PATH=..." lines since they're
now at Trace level and won't appear in Debug output.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>

* address comments, add tests

* address comments, add tests

* address comments, add tests

* test: Add ATMOS_CLI_CONFIG_PATH isolation to fix Windows CI timeouts

Tests in internal/exec/ that use t.Chdir() without setting
ATMOS_CLI_CONFIG_PATH trigger expensive git root discovery and
parent directory search operations on every InitCliConfig() call.

On Windows, these git operations are significantly slower, causing
the test suite to timeout after 30 minutes.

This fix adds t.Setenv("ATMOS_CLI_CONFIG_PATH", ".") after each
t.Chdir() call to:
- Disable parent directory search for atmos.yaml
- Disable git root discovery
- Isolate tests from the repository's atmos.yaml

Files modified:
- component_path_resolution_test.go
- describe_affected_authmanager_test.go
- describe_component_auth_override_test.go
- describe_component_authmanager_test.go
- describe_component_provenance_test.go
- describe_component_test.go
- describe_dependents_authmanager_propagation_test.go
- describe_dependents_test.go
- describe_stacks_authmanager_propagation_test.go
- describe_stacks_test.go
- validate_component_test.go
- yaml_func_template_test.go

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

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: Prevent kubeconfig_path inheritance in demo-helmfile example

The git root discovery feature (added in #1773) causes the repo root's
atmos.yaml configuration to be inherited by examples. This resulted in
the demo-helmfile example inheriting kubeconfig_path: "/dev/shm" from
the repo root, which overwrote the KUBECONFIG env var set by the CI
workflow.

The fix explicitly sets kubeconfig_path: "" in the demo-helmfile's
atmos.yaml to prevent this inheritance, allowing the CI-provided
KUBECONFIG env var to be used.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* address comments, add tests

* fix Windows tests

* address comments

* fix Windows tests

* update deps

* [autofix.ci] apply automated fixes

* updates

* [autofix.ci] apply automated fixes

* updates

* address comments, add tests

* address comments, add tests

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Erik Osterman <erik@cloudposse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/xl Extra large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants