This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Clockify CLI is a command-line tool for managing time entries and projects on Clockify from the terminal. It's written in Go and built on the Cobra framework for CLI command handling.
Key Technologies:
- Go 1.24+ (module-based)
- Cobra for CLI commands
- Viper for configuration management
- Survey for interactive prompts
- GoReleaser for releases
make deps-install # Install Go dependenciesmake go-install # Build and install dev version to $GOBIN
make dist # Build all versions (darwin, linux, windows) → dist/
go run cmd/clockify-cli/main.go <args> # Run directly from sourcemake test # Run all tests with gotestsum
make test-watch # Run tests with file watcher (fails fast)
make test-coverage # Run tests with coverage reportmake go-generate # Regenerate mocks using mockery-
cmd/- Main executable packagescmd/clockify-cli/main.go- Entry point (version info, error handling, Viper config binding)cmd/release/- Release automationcmd/gendocs/- Documentation generation
-
api/- Clockify API client implementationapi/client.go- Main HTTP client for API callsapi/dto/- Data transfer objects and request builders
-
pkg/cmd/- CLI command implementation (follows directory-based routing)- Subdirectories for command groups:
client/,config/,project/,tag/,task/,time-entry/,user/,version/,workspace/ - Pattern: Command at
pkg/cmd/<entity>/<subcommand>/<subcommand>.go - Each command has a
NewCmd<SubCommand>()factory function returning*cobra.Command
- Subdirectories for command groups:
-
pkg/output/- Output formatters- Pattern:
pkg/output/<entity>/<format>.go - Formats: table (default), json, quiet (ID only), template (Go template), csv
- Pattern:
-
pkg/- Shared packagescmdutil/- Command utilities, configuration constants (CONF_TOKEN, CONF_WORKSPACE, etc.)cmdcomplutil/- Completion utilitiesoutpututil/- Shared output logictimeentryhlp/,timehlp/- Time entry and time helpersui/- UI components (prompts, selections)
-
internal/- Project-specific test utilitiestesthlp/- Test helpersconsoletest/- Console testing utilitiesmocks/- Generated mocks
Commands follow the Cobra pattern:
- Factory Functions: Each command is created via
NewCmd<Name>(factory cmdutil.Factory) *cobra.Command - Command Groups: Parent commands register subcommands (e.g.,
pkg/cmd/client/client.goregisters its subcommands) - Configuration: Commands access config through
factory.Config()which reads from:- Environment variables (prefix:
CLOCKIFY_) - Config file:
~/.config/clockify-cli/config.yamlor~/.clockify-cli - CLI flags (with viper binding)
- Environment variables (prefix:
Adding a New Command:
- Create
pkg/cmd/<entity>/<subcommand>/<subcommand>.go - Implement
NewCmd<SubCommand>(factory cmdutil.Factory) *cobra.Command - Register in parent command's
NewCmd<Entity>()function - If first command for entity, create output formatters at
pkg/output/<entity>/for: table, json, quiet, template, csv
- Configuration keys: Defined in
pkg/cmdutil/(e.g.,CONF_TOKEN,CONF_WORKSPACE,CONF_USER_ID) - CLI Flags: Bound to Viper config via
bindViper()in main.go, allowing env var and config file overrides - Environment Variables: Use
CLOCKIFY_prefix (e.g.,CLOCKIFY_TOKEN,CLOCKIFY_WORKSPACE) - Output: Commands use output formatters from
pkg/output/to support multiple formats - Mocks: Generated by
mockeryduringmake go-generate— run this before testing if interfaces change
- Framework: testify assertions + gotestsum runner
- Test Discovery:
**/*_test.gopattern - Mocks:
internal/mocks/— regenerate withmake go-generatewhen interfaces change - Flags: Use
-failfastinmake test-watch(configured in Makefile)
Every code change must be documented in CHANGELOG.md under the ## [Unreleased] section. Follow the Keep a Changelog format:
- Added — for new features or functionality
- Changed — for changes to existing functionality
- Deprecated — for soon-to-be removed features
- Removed — for removed features
- Fixed — for bug fixes
- Security — for security fixes
Each change is one bullet point written from the user's perspective (what changed, not implementation details). Do not commit changes without updating the changelog first.
Always ask the user for permission before creating any commit. Do not run git commit without explicit user approval — confirm what will be committed and ask for approval before proceeding.