Skip to content

Commit b32fe67

Browse files
authored
chore: add AGENTS.md and symlink CLAUDE.md (#655)
Add agents.md and claude.md (symlinked) files for agentic coding
1 parent 9b40133 commit b32fe67

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI coding agents when working with code in this repository.
4+
5+
## Project Overview
6+
7+
LaunchDarkly CLI (`ldcli`) — a Go CLI for managing LaunchDarkly feature flags. Built with Cobra/Viper, distributed via Homebrew, Docker, NPM, and GitHub Releases.
8+
9+
## Common Commands
10+
11+
```bash
12+
make build # Build binary as ./ldcli
13+
make test # Run all tests (go test ./...)
14+
go test ./path/to/pkg # Run tests for a specific package
15+
make generate # Regenerate code from OpenAPI spec (go generate ./...)
16+
make vendor # Tidy and vendor dependencies
17+
make install-hooks # Install git pre-commit hooks
18+
make openapi-spec-update # Download latest OpenAPI spec and regenerate code
19+
```
20+
21+
## Code Generation
22+
23+
Resource commands are auto-generated from the LaunchDarkly OpenAPI spec (`ld-openapi.json`):
24+
25+
- **Generator:** `cmd/resources/gen_resources.go` (build tag: `gen_resources`)
26+
- **Template:** `cmd/resources/resource_cmds.tmpl`
27+
- **Output:** `cmd/resources/resource_cmds.go` (~613KB, do not edit manually)
28+
- **Trigger:** `//go:generate` directive in `cmd/root.go`
29+
30+
The dev server API is also generated: `internal/dev_server/api/server.gen.go` (via oapi-codegen).
31+
32+
## Architecture
33+
34+
**Entry point:** `main.go``cmd.Execute(version)``cmd/root.go` (Cobra root command)
35+
36+
**Command layer (`cmd/`):**
37+
- Each subcommand (flags, members, config, login, dev-server, sourcemaps, resources) has its own package
38+
- Resource commands are generated; custom commands are hand-written
39+
- Analytics tracking via `PersistentPreRun` hooks
40+
41+
**Internal packages (`internal/`):**
42+
- Each domain package (flags, environments, members, projects, resources, dev_server) exposes a `Client` interface for dependency injection
43+
- `internal/dev_server/` — local dev server with SQLite storage, embedded React UI, and LaunchDarkly SDK integration
44+
- `internal/config/` — manages CLI configuration via `$XDG_CONFIG_HOME/ldcli/config.yml`
45+
- `internal/output/` — response formatting (JSON/plaintext)
46+
47+
**Configuration precedence:** CLI flags → environment variables (prefix `LD_`) → config file
48+
49+
## Adding a New Command
50+
51+
1. Add command to root via `cmd.AddCommand` in `NewRootCommand()` in `cmd/root.go`
52+
2. Update usage template in `getUsageTemplate()` in `cmd/root.go`
53+
3. Add analytics instrumentation via `PersistentPreRun` calling `tracker.SendCommandRunEvent`
54+
55+
## Dev Server Frontend
56+
57+
Located at `internal/dev_server/ui/` — React 18 + TypeScript + Vite, embedded into the Go binary.
58+
59+
```bash
60+
cd internal/dev_server/ui
61+
npm ci
62+
npm test # Vitest
63+
npm run lint # ESLint
64+
npm run build # Production build (checked into repo)
65+
```
66+
67+
## Testing
68+
69+
- Go tests use `testify` for assertions and `go.uber.org/mock` for mocking
70+
- Mock generation via `mockgen`
71+
- Test data in `cmd/resources/test_data/` and `cmd/config/testdata/`
72+
73+
## Pre-commit Hooks
74+
75+
Installed via `make install-hooks`. Checks:
76+
- `go fmt` formatting
77+
- `go.mod`/`go.sum` tidiness
78+
- Dev server UI tests and build (requires npm)
79+
80+
## Linting
81+
82+
- Go: `golangci-lint` (v1.63.4) via pre-commit
83+
- Frontend: ESLint + Prettier

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

0 commit comments

Comments
 (0)