Skip to content

Running Health Checks

The doctor command runs a series of health checks on your Kānuka project and provides actionable suggestions for any issues found.

To check the health of your project:

Terminal window
kanuka secrets doctor

This runs all health checks and displays the results:

Running health checks...
[pass] Project configuration valid
[pass] User configuration valid
[pass] Private key exists for this project
[pass] Private key permissions correct (0600)
[pass] All public keys have corresponding .kanuka files
[pass] All .kanuka files have corresponding public keys
[pass] .env patterns found in .gitignore
[warn] Found 1 unencrypted .env file (run 'kanuka secrets status')
[fail] 2 .env files not in .gitignore
Summary: 7 passed, 1 warning, 1 error
Suggestions:
- Run 'kanuka secrets encrypt' to encrypt unprotected files
- Add '.env*' to your .gitignore file

Each check can have one of three results:

ResultMeaning
passCheck passed, no issues found
warnPotential issue that should be addressed
failCritical issue that needs immediate attention

The doctor command runs these checks:

CheckSeverityWhat it checks
Project configurationfail.kanuka/config.toml exists and is valid
User configurationfailUser config exists and is valid
Private key existsfailPrivate key file exists for this project
Private key permissionswarnPrivate key has secure permissions (0600)
Public key consistencyfailEvery public key has a matching .kanuka file
Kānuka file consistencyfailEvery .kanuka user file has a matching public key
Gitignore patternswarn.env patterns are in .gitignore
Unencrypted fileswarnNo plaintext .env files without encryption

The doctor command uses exit codes to indicate overall health:

Exit codeMeaning
0All checks passed
1Warnings found (but no errors)
2Errors found

This makes it easy to use in scripts and CI pipelines:

Terminal window
if kanuka secrets doctor; then
echo "Project is healthy"
else
echo "Issues found, check output above"
fi

For scripting and automation, use the --json flag:

Terminal window
kanuka secrets doctor --json

This outputs machine-readable JSON:

{
"checks": [
{"name": "Project configuration valid", "status": "pass", "message": ""},
{"name": "Private key permissions", "status": "warn", "message": "Permissions are 0644, should be 0600", "suggestion": "Run: chmod 600 ~/.kanuka/keys/project-uuid.pem"}
],
"summary": {"pass": 7, "warn": 1, "fail": 1},
"healthy": false
}
Terminal window
# Run all health checks
kanuka secrets doctor
# JSON output for scripting
kanuka secrets doctor --json
# Use in CI to fail on any issues
kanuka secrets doctor || exit 1
Terminal window
# Fix permissions on your private key
chmod 600 ~/.kanuka/keys/<project-uuid>.pem

Add these patterns to your .gitignore:

# Environment files
.env
.env.*
!.env.example
!.env.*.kanuka
Terminal window
# Encrypt all .env files
kanuka secrets encrypt

Inconsistent user state (orphans or pending)

Section titled “Inconsistent user state (orphans or pending)”
Terminal window
# View current access state
kanuka secrets access
# Clean up orphaned entries
kanuka secrets clean
# Grant access to pending users
kanuka secrets sync