Skip to content

Commit 214ffbc

Browse files
AnnatarHeclaude
andcommitted
docs(claude): expand CLAUDE.md with Go version, testing patterns, daemon services, and dependencies
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 71a3574 commit 214ffbc

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ShellTime CLI is a Go-based command-line tool for tracking DevOps work. It consi
1010

1111
## Development Commands
1212

13+
**Requires Go 1.25+**
14+
1315
### Building
1416
```bash
1517
# Build the CLI binary
@@ -36,12 +38,19 @@ go test ./model/...
3638
go test -run TestHandlerName ./daemon/
3739
```
3840

41+
Tests use **testify** (assertions + suites). Suite-based tests use `suite.Suite` with `SetupTest`/`TearDownTest` lifecycle hooks (see `daemon/cc_info_handler_test.go` for example). Simple functions use table-driven tests.
42+
3943
### Code Generation
4044
```bash
41-
# Generate mocks (uses .mockery.yml configuration)
45+
# Generate mocks (uses .mockery.yml configuration, Mockery v3)
4246
mockery
47+
48+
# Generate PromptPal types (requires pp CLI and API token)
49+
pp g
4350
```
4451

52+
CI runs both `mockery` and `pp g` before tests. Generated files: `model/pp.types.g.go` (PromptPal types), `model/mock_*.go` (testify mocks for service interfaces).
53+
4554
### Linting
4655
```bash
4756
go vet ./...
@@ -69,7 +78,16 @@ Injection happens in `cmd/*/main.go` via `commands.InjectVar()` and `commands.In
6978
1. **SocketHandler**: Unix domain socket server accepting JSON messages from CLI
7079
2. **GoChannel**: Watermill pub/sub for decoupled message processing
7180
3. **SocketTopicProcessor**: Consumes messages and routes to appropriate handlers
72-
4. **AICodeOtelServer** (optional): gRPC server implementing OTEL collector for AI coding CLI metrics/logs passthrough (Claude Code, Codex, etc.)
81+
82+
Optional daemon services (feature-gated via config):
83+
- **CCInfoTimerService**: Lazy-fetch background timer for Claude Code statusline data (cost, quota, git info)
84+
- **SyncCircuitBreakerService**: Retry failed syncs with file-based persistence (`sync_pending.log`) and hourly recovery timer
85+
- **AICodeOtelServer**: gRPC OTEL collector for AI coding CLI metrics/logs (Claude Code, Codex)
86+
- **HeartbeatResyncService**: Periodic resync of failed heartbeats (30-min interval)
87+
- **CleanupTimerService**: Periodic log file cleanup (24-hour interval)
88+
- **CCUsageService**: Integration with ccusage CLI
89+
90+
Services initialize in `cmd/daemon/main.go`: check enabled flag → create → start → defer stop. All run concurrently with graceful shutdown on SIGINT/SIGTERM.
7391

7492
### Data Flow
7593
1. Shell hooks capture commands → CLI stores locally (file-based buffer)
@@ -87,9 +105,24 @@ Injection happens in `cmd/*/main.go` via `commands.InjectVar()` and `commands.In
87105

88106
Follow Conventional Commits with scope: `fix(daemon): ...`, `feat(cli): ...`, `refactor(model): ...`
89107

108+
## Key Dependencies
109+
110+
- **CLI Framework**: `urfave/cli/v2`
111+
- **Message Queue**: `ThreeDotsLabs/watermill` (in-process pub/sub for daemon)
112+
- **AI Integration**: `PromptPal/go-sdk` with generated types from `promptpal.yml`
113+
- **Telemetry**: `uptrace-go` for OTEL
114+
- **Config**: `pelletier/go-toml/v2`
115+
- **Git**: `go-git/v5` for branch/dirty detection
116+
- **gRPC**: OTEL collector protos for AICodeOtel server
117+
118+
## Release
119+
120+
Releases use Release-Please (always-bump-patch) + Goreleaser. macOS builds include code signing/notarization via Quill when credentials are present. CI config in `.github/workflows/`.
121+
90122
## Important Notes
91123

92124
- Daemon is optional but recommended (<8ms latency vs ~100ms+ direct)
93125
- Encryption requires daemon mode and a token with encryption capability
94126
- Shell hooks are platform-specific (bash, zsh, fish) - test on target shells
127+
- CC statusline quota display is macOS-only (requires Keychain access to Claude Code OAuth token)
95128
- AICodeOtel feature enables AI coding CLI metrics/logs passthrough via gRPC (port 54027) - supports Claude Code, Codex, and other OTEL-compatible CLIs

0 commit comments

Comments
 (0)