openclaw-dashboard
CLAUDE.md457 starsChanged 3 months agoMITView on GitHub
Zero-dependency Go HTTP server with embedded SPA frontend for OpenClaw bot metrics. Check each project's Makefile for exact targets. Common conventions: After writing code: Write modern Go — never generate pre-1.24 patterns when go.mod allows it. Key features: new(expr), self-referential generics, iter.Seq/iter.Seq2, range-over-func, omitzero struct tags, generic type aliases. See .claude/rules/go-idioms.md for the full catalog and go fix modernizers. Domain-oriented packages as default. Avoid helpers, util, common. Wrap with %w. Branch with errors.Is/errors.As. Lowercase, no trailing punctuation. Never swallow. Never…
The file
We split this CLAUDE.md into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Treat go.mod, toolchain, CI config as the source of truth
- Very specific: line 28
Prefer make targets over raw commands when a Makefile exists
- Distinctive: line 35
Check each project's Makefile for exact targets.
- Very specific: line 57
Write modern Go — never generate pre-1.24 patterns when go.mod allows it.
- Distinctive: line 94
Only when it measurably helps.
- Very specific: line 106
Logging: prefer slog (stdlib, structured) for new code.
- Distinctive: line 107
Config: no hardcoded values. Load + validate at startup.
- Very specific: line 113
Use conventional commit format: type(scope): message
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Development Standards
Zero-dependency Go HTTP server with embedded SPA frontend for OpenClaw bot metrics.
Project Constraints
- Zero third-party dependencies —
go.modhas norequireblock, nogo.sum. Do not suggest adding external packages. Use stdlib only. - Embedded frontend —
web/index.htmlis compiled into the binary via//go:embed. Frontend changes require a rebuild. - Root-package facade — Logic lives in
internal/app<domain>/packages. The rootdashboardpackage has thin wrapper functions and type aliases that re-export internal APIs. New features: (1) add logic tointernal/, (2) add root-level wrappers, (3) test at both levels.
Internal Packages
| Package | Purpose |
appconfig | Config struct definitions, JSON loading, dotenv |
appruntime | Directory resolution (repo root vs Homebrew), version detection |
appchat | AI gateway HTTP communication, system prompt building |
apprefresh | Core data collector: sessions, tokens, crons, daily aggregation |
appserver | HTTP server, routing, caching, rate limiting |
appsystem | System metrics (CPU/RAM/disk), version probes, OpenClaw runtime |
appservice | OS service management (launchd/systemd) |
appopenclaw | Bounded access to the selected OpenClaw runtime: CLI target selection, gateway RPC reads, allow-listed operations, secret redaction |
Environment
- Go 1.27 (toolchain
go1.27.1pergo.mod), darwin/arm64 + linux/amd64+arm64 - Treat
go.mod,toolchain, CI config as the source of truth - Prefer
maketargets over raw commands when a Makefile exists make checkis the canonical gate:vet,lint(golangci-lint withgosec+errorlintenabled),test -race,govulncheckCGO_ENABLED=0is set across all four build paths (Makefile,Dockerfile,.goreleaser.yml,flake.nix); keep it that way- Loopback-only HTTP bind is enforced at startup; container deployments opt in via
OPENCLAW_DASHBOARD_ALLOW_NON_LOOPBACK=1
Commands
Check each project's Makefile for exact targets. Common conventions:
make build # build binary
make test # go test ./...
make lint # golangci-lint
make fmt # gofmt / gofumpt
make ci # full gate (or make check, make all)After writing code:
go vet ./... # always run first — catches misuse before lint
go fix ./... # applies modernizations in-place; review with git diff
go test ./...
go test -race ./... # when the package has race support
go mod tidy # only when imports or dependencies changedGo 1.27 Idioms
Write modern Go — never generate pre-1.24 patterns when go.mod allows it. Key features: new(expr), self-referential generics, iter.Seq/iter.Seq2, range-over-func, omitzero struct tags, generic type aliases. See .claude/rules/go-idioms.md for the full catalog and go fix modernizers.
Layout
cmd/<binary>/main.go # multi-command repo
internal/<domain>/ # domain-organized, not layer-organized
pkg/ # rare — only intentionally reusable public packages
*_test.go # next to the package under test
tests/ # optional acceptance/integration/e2e suitesDomain-oriented packages as default. Avoid helpers, util, common.
Style
- Formatting is mechanical:
gofmt/go fmt— do not hand-format - Standard library first;
x/before third-party; justify every dependency - Concrete types over premature abstractions; unexport by default
- Interfaces: consumer-side, 1–3 methods, accept interfaces return structs
- Early returns; whitespace to separate phases; functions readable in one pass
- See
.claude/rules/go-patterns.mdfor naming, API design, and documentation rules
Errors
return fmt.Errorf("create order: %w", err)Wrap with %w. Branch with errors.Is/errors.As. Lowercase, no trailing punctuation. Never swallow. Never panic for expected failures. Context in, internals never out.
Context
First parameter for I/O. Never in struct. Never nil. Cancellation + deadlines + request metadata only.
Concurrency
Only when it measurably helps. Every goroutine needs a shutdown path. Context cancellation for background work. No concurrent map writes without sync. Race detector in CI.
Testing
- Table-driven with
t.Run, helpers witht.Helper() - Fakes/stubs over mocks — test behavior not implementation
- Deterministic seams for time, randomness, I/O
cmp.Equal/cmp.Difffor complex comparisons- See
.claude/rules/go-patterns.mdfor detailed testing APIs
Common Patterns
- Logging: prefer
slog(stdlib, structured) for new code; match existing convention in existing projects. Never log secrets. - Config: no hardcoded values. Load + validate at startup. Secrets from env or secret manager.
- HTTP / DB: set timeouts deliberately. Always close rows/bodies.
- Security:
govulncheck ./...when deps changed or before release; include in CI.
Commits
Use conventional commit format: type(scope): message
Types: feat, fix, refactor, test, perf, docs, chore
Scopes: refresh, server, system, chat, config, service, runtime, web
Review Rejects
Premature abstractions · swallowed errors · context misuse · goroutine leaks · unsafe shared state · unnecessary deps · behavior-changing go fix applied blindly · transport in domain · missing tests · secrets in code · pre-1.24 patterns when go.mod allows modern · magic values · giant mixed-responsibility functions
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

