The thothctl check command group provides tools for validating various aspects of your infrastructure code, project structure, and development environment. These commands help ensure that your projects follow best practices, adhere to defined structures, and meet security requirements.
Validates the development environment and required tools installation.
thothctl check environment
This command validates:
Provides comprehensive diagnostics for space configuration and setup.
thothctl check space --space-name <space_name>
This command validates:
Validates Infrastructure as Code (IaC) project source code structure against predefined rules and best practices.
# Validate full stack project
thothctl check project iac -p stack
# Validate single module
thothctl check project iac -p module
This command validates:
Project Types:
stack - Full project with modules, environments, etc. (default)module - Single reusable Terraform moduleSee detailed documentation for complete usage guide.
Analyzes IaC generated artifacts including terraform plans, dependencies, costs, and blast radius.
# Analyze terraform plan
thothctl check iac -type tfplan --recursive
# Analyze dependencies
thothctl check iac -type deps --recursive
# Assess blast radius (ITIL v4 compliant)
thothctl check iac -type blast-radius --recursive
# Estimate infrastructure costs
thothctl check iac -type cost-analysis --recursive
# Detect infrastructure drift
thothctl check iac -type drift --recursive
# Optimize overlapping stack filters
thothctl check iac -type stack-optimizer --stacks "Network/**,Compute/EC2/**"
# Post results as a PR comment in CI/CD
thothctl check iac -type tfplan --recursive --post-to-pr
Available check types:
See detailed documentation for complete usage guide.
ITIL v4 compliant risk assessment that combines dependency analysis with planned changes to assess deployment impact.
thothctl check iac -type blast-radius --recursive --plan-file tfplan.json
Features:
Detect infrastructure drift between your IaC definitions and live cloud resources.
thothctl check iac -type drift --recursive --filter-tags "env=prod"
Features:
--filter-tags "env=prod,team=*").driftpolicy with block/alert/accept/ignore actions).driftignore file support for excluding known-unmanaged resourcesThe check commands follow a hierarchical structure:
thothctl check
├── environment # Environment and tools validation
├── space # Space configuration diagnostics
└── project # Project-specific validations
└── iac # Infrastructure as Code structure validation
Most check commands support the following options:
| **–mode [soft | strict]**: Determines validation strictness level |
All check commands provide Rich-formatted output with:
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 🏗️ Infrastructure as Code Project Structure Check │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
🏗️ Root Structure
╭───────────────────────────┬──────────┬────────────┬────────────┬────────────────────────────────╮
│ Item │ Type │ Required │ Status │ Details │
├───────────────────────────┼──────────┼────────────┼────────────┼────────────────────────────────┤
│ common │ 📁 │ Required │ ✅ Pass │ . │
│ docs │ 📁 │ Required │ ✅ Pass │ . │
╰───────────────────────────┴──────────┴────────────┴────────────┴────────────────────────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── Summary ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✅ IaC project structure validation passed │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Add check commands to your CI/CD pipeline to validate infrastructure code before deployment:
# Example GitHub Actions workflow
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install ThothCTL
run: pip install thothctl
- name: Check Environment
run: thothctl check environment
- name: Check Space Configuration
run: thothctl check space --space-name $
- name: Validate IaC Structure
run: thothctl check project iac --mode strict
- name: Analyze Plan and Post to PR
run: thothctl check iac -type tfplan --recursive --post-to-pr
env:
GITHUB_TOKEN: $
The --post-to-pr flag automatically posts check results as a pull request comment. It supports GitHub Actions and Azure Pipelines, with auto-detection of the CI environment. See check iac documentation for details.
Use check commands in pre-commit hooks to validate changes before committing:
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: thothctl-check-environment
name: ThothCTL Check Environment
entry: thothctl check environment
language: system
pass_filenames: false
- id: thothctl-check-project-iac
name: ThothCTL Check Project IaC
entry: thothctl check project iac
language: system
pass_filenames: false
Run check commands during development to ensure your environment and code meet requirements:
# Check development environment setup
thothctl check environment
# Validate space configuration before project operations
thothctl check space --space-name development
# Validate project structure before committing
thothctl check project iac
# Strict validation for production readiness
thothctl check project iac --mode strict
Environment checks use version_tools.py as the single source of truth for tool versions and installation methods.
Project structure validation uses .thothcf_project.toml template files for configuration:
[project_structure]
root_files = [
".gitignore",
".pre-commit-config.yaml",
"README.md",
"root.hcl"
]
[[project_structure.folders]]
name = "modules"
mandatory = true
type = "root"
content = [
"variables.tf",
"main.tf",
"outputs.tf",
"README.md"
]
.thothcf_project.toml files to define project structure rulesAll check commands follow consistent exit code patterns:
Using default options
Solution: Create appropriate .thothcf_project.toml configuration files.
❌ terraform: 1.5.0 (recommended: 1.6.0)
Solution: Update tools to recommended versions or adjust version requirements.
Error: [Errno 13] Permission denied
Solution: Ensure proper read/write permissions for directories being validated.
Enable debug mode for detailed logging:
thothctl --debug check environment
thothctl --debug check project iac
ThothCTL’s modular architecture allows for easy extension of check commands:
src/thothctl/services/check/src/thothctl/commands/check/commands/