@@ -8,10 +8,26 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88- ** Hatch** as the build system and project manager
99- ** Python 3.12+** as the minimum required version
1010- ** pydantic-settings** for configuration management
11+ - ** structlog** for structured logging
1112- ** AGPL-3.0** license
1213
1314## Development Commands
1415
16+ ### Running the Application
17+ ``` bash
18+ # Run with hatch (preferred method)
19+ hatch run compile-flags [options]
20+
21+ # Examples:
22+ hatch run compile-flags --help
23+ hatch run compile-flags -v # INFO level logging
24+ hatch run compile-flags -vv # DEBUG level logging
25+ hatch run compile-flags -vv -l rust -b /path/to/build
26+
27+ # Run directly via Python module
28+ hatch run python -m compile_flags [options]
29+ ```
30+
1531### Package Management
1632``` bash
1733# Install in development mode
@@ -21,15 +37,6 @@ hatch shell
2137hatch build
2238```
2339
24- ### Testing
25- ``` bash
26- # Run tests (when test framework is added)
27- hatch test
28-
29- # Run tests with coverage
30- hatch test --cover
31- ```
32-
3340### Type Checking
3441``` bash
3542# Run mypy type checker
@@ -39,19 +46,46 @@ hatch run types:check
3946hatch run types:check compile_flags/module.py
4047```
4148
42- ## Project Structure
49+ ## Architecture
50+
51+ ### Configuration System
52+ The application uses a hybrid approach combining ** argparse** for CLI parsing with ** Pydantic Settings** for configuration management:
53+
54+ 1 . ** CLI Parsing (` __main__.py ` )** : Uses argparse with ` action="count" ` to support ` -v ` , ` -vv ` , ` -vvv ` verbosity levels
55+ 2 . ** Configuration Model (` config.py ` )** : Pydantic ` BaseSettings ` model that:
56+ - Validates all configuration values with type safety
57+ - Uses ` @model_validator ` to compute ` log_level ` from ` verbose ` count
58+ - Integrates with ` CliApp.run() ` pattern via ` CliSettingsSource `
59+
60+ ### Logging System
61+ - ** structlog** for structured logging with colored console output
62+ - Log levels mapped from verbosity: 0=WARNING, 1=INFO, 2+=DEBUG
63+ - Configuration in ` config.py:configure_logging() `
64+ - All log messages include structured key-value pairs for better debugging
65+
66+ ### Entry Point Flow
67+ ```
68+ __main__.py:parse_args()
69+ → CliApp.run(Config, cli_settings_source=...)
70+ → config.py:compute_log_level() (model_validator)
71+ → __main__.py:configure_logging()
72+ → Application logic with structured logging
73+ ```
74+
75+ ## Code Style
4376
44- - ` compile_flags/ ` - Main package source code
45- - ` __about__.py ` - Version information
46- - ` __init__.py ` - Package initialization
47- - ` tests/ ` - Test suite (pytest-based)
48- - ` pyproject.toml ` - Project configuration and dependencies
77+ - Use modern Python type hints: ` dict ` not ` Dict ` , ` | None ` not ` Optional `
78+ - Type annotate everything: variables, function arguments, and return types
79+ - All source files must include SPDX license headers (MIT for code files)
80+ - Version is managed in ` compile_flags/__about__.py `
4981
5082## Important Notes
5183
52- - The project uses modern Python type hints (e.g., ` dict ` instead of ` Dict ` , ` | None ` instead of ` Optional ` )
53- - Version is managed in ` compile_flags/__about__.py ` (note: pyproject.toml incorrectly references ` src/compile_flags/__about__.py ` )
54- - Coverage configuration excludes ` __about__.py ` from coverage reports
55- - All source files include SPDX license headers (MIT for code files)
56- - Use modern Python annotations, for example, use "| None" instead of "Optional".
57- - Type annotate everything, including variables, function arguments, and function returns.
84+ - The hatch script at ` pyproject.toml:39 ` uses ` {args} ` to pass CLI arguments through
85+ - When adding CLI arguments, update both ` parse_args() ` in ` __main__.py ` and the corresponding field in ` Config ` model
86+ - The ` Config ` model has ` case_sensitive=False ` for environment variable support
87+ - Environment variables can override defaults using ` COMPILE_FLAGS_ ` prefix
88+ - Use modern Python type hints: ` dict ` not ` Dict ` , ` | None ` not ` Optional `
89+ - Type annotate everything: variables, function arguments, and return types
90+ - All source files must include SPDX license headers (AGPL-3.0 for source files)
91+ - Version is managed in ` compile_flags/__about__.py `
0 commit comments