Skip to content

feat: check-env CLI command for config validation#171

Merged
ichoosetoaccept merged 1 commit intomainfrom
02-17-feat-check-env-cli-command-for-config-validation
Feb 17, 2026
Merged

feat: check-env CLI command for config validation#171
ichoosetoaccept merged 1 commit intomainfrom
02-17-feat-check-env-cli-command-for-config-validation

Conversation

@ichoosetoaccept
Copy link
Member

@ichoosetoaccept ichoosetoaccept commented Feb 17, 2026

Add a codereviewbuddy check-env CLI command for validating CRB_* environment variables before starting the server. Built on cyclopts — the same CLI framework FastMCP uses.

What it does

  • Lists all CRB_* env vars and their current values (masking sensitive ones)
  • Validates types and constraints via load_config()
  • Warns about unrecognized CRB_* env vars (typo detection)
  • Checks gh CLI authentication

Changes

  • New src/codereviewbuddy/cli.py with cyclopts app, serve (default) and check-env commands
  • Entry point changed from server:main to cli:app
  • Removed main() from server.py (moved to cli.serve())
  • pyproject.toml: added T201 per-file ignore for cli.py
  • 11 new tests in tests/test_cli.py

Fixes #160

@greptile-apps
Copy link

greptile-apps bot commented Feb 17, 2026

Greptile Summary

Adds codereviewbuddy check-env CLI command for validating configuration before starting the server. Built on cyclopts framework, this provides a diagnostic tool that lists all CRB_* environment variables (masking sensitive values), validates their types and constraints via load_config(), detects typos in unrecognized vars, and checks gh CLI authentication status.

Key changes:

  • New cli.py module with cyclopts app structure: serve as default command and check-env for diagnostics
  • Entry point changed from server:main to cli:app in pyproject.toml
  • main() removed from server.py (functionality moved to cli.serve())
  • Sensitive value masking shows first/last 2 chars for values >4 chars, full mask for shorter values
  • 11 new test cases with good edge case coverage
  • Proper T201 linter exception added for CLI print statements

Confidence Score: 5/5

  • Safe to merge - well-structured refactor with comprehensive tests and clear separation of concerns
  • Clean implementation with proper error handling, comprehensive test coverage (11 new tests covering edge cases), sensible defaults, and no breaking changes to existing functionality. The masking logic is secure, the refactoring is minimal and focused, and all integration points are properly tested
  • No files require special attention

Important Files Changed

Filename Overview
src/codereviewbuddy/cli.py Adds new CLI with cyclopts for serve (default) and check-env commands, masking sensitive env vars and validating config
tests/test_cli.py Comprehensive test coverage for CLI helpers and check_env command with 11 test cases
pyproject.toml Updates entry point to cli:app and adds T201 ignore for cli.py (print statements by design)

Flowchart

flowchart TD
    A[codereviewbuddy CLI] --> B{Command?}
    B -->|default| C[serve]
    B -->|check-env| D[check_env]
    
    C --> C1[install_io_tap]
    C1 --> C2[mcp.run]
    
    D --> D1[Collect CRB_* env vars]
    D1 --> D2[Check against known prefixes]
    D2 --> D3[Display vars with masking]
    D3 --> D4{Unknown vars?}
    D4 -->|yes| D5[Warn about typos]
    D4 -->|no| D6[Continue]
    D5 --> D6
    D6 --> D7[load_config validation]
    D7 --> D8{Config valid?}
    D8 -->|no| D9[Print error & exit 1]
    D8 -->|yes| D10[Print config summary]
    D10 --> D11[gh.check_auth]
    D11 --> D12{gh CLI ok?}
    D12 -->|yes| D13[Print authenticated user]
    D12 -->|no| D14[Print error]
    D13 --> D15[Exit 0]
    D14 --> D15
Loading

Last reviewed commit: 1890ec7

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@ichoosetoaccept ichoosetoaccept force-pushed the 02-17-fix-per-pr-error-handling-in-review_pr_descriptions branch from 6b87f2e to be51d91 Compare February 17, 2026 10:10
@ichoosetoaccept ichoosetoaccept force-pushed the 02-17-feat-check-env-cli-command-for-config-validation branch from f9cb677 to 26242ca Compare February 17, 2026 10:10
Copy link
Member Author

ichoosetoaccept commented Feb 17, 2026

Merge activity

  • Feb 17, 11:17 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 17, 11:23 AM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 17, 11:23 AM UTC: @ichoosetoaccept merged this pull request with Graphite.

@ichoosetoaccept ichoosetoaccept changed the base branch from 02-17-fix-per-pr-error-handling-in-review_pr_descriptions to graphite-base/171 February 17, 2026 11:20
@ichoosetoaccept ichoosetoaccept changed the base branch from graphite-base/171 to main February 17, 2026 11:21
@ichoosetoaccept ichoosetoaccept force-pushed the 02-17-feat-check-env-cli-command-for-config-validation branch from 26242ca to 1890ec7 Compare February 17, 2026 11:22
@ichoosetoaccept ichoosetoaccept merged commit 2de925c into main Feb 17, 2026
7 checks passed
@ichoosetoaccept ichoosetoaccept deleted the 02-17-feat-check-env-cli-command-for-config-validation branch February 17, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: check-env CLI command for config validation

1 participant