Guidance for agentic coding assistants working in github.com/ncode/pretty.
Run these first from repo root:
go env -w GOTOOLCHAIN=go1.25.0+autogofmt -w .go test -v ./...
When narrowing scope:
- Single package:
go test -v ./internal/shell - Single test:
go test -v ./internal/shell -run '^TestParseCommandAsync$' - Subtest:
go test -v ./cmd -run '^TestParseHostSpec$/host_with_port$'
- Language: Go (
go 1.25ingo.mod) - Binary entrypoint:
main.go - CLI layer:
cmd/ - Core packages:
internal/shell,internal/sshConn,internal/jobs - Main user docs:
README.md
- Use Go 1.25.
- Match CI behavior when possible:
go env -w GOTOOLCHAIN=go1.25.0+auto
- A
Makefileis provided. Runmaketo build,make testfor tests,make demofor the full testbed workflow. - No dedicated linter config (
.golangci.yml) is present.
Run from repository root.
- Build all packages:
go build -v ./... - Build binary only:
go build -o pretty .
- Full suite:
go test -v ./... - Full suite with race detector:
go test -race ./... - CI-like coverage command:
go test -coverpkg=./... ./... -race -coverprofile=coverage.out -covermode=atomic
- Single package:
go test -v ./internal/shell
- Single test function:
go test -v ./internal/shell -run '^TestParseCommandAsync$'
- Single test in another package:
go test -v ./cmd -run '^TestParseHostSpec$'
- Subtest target (table-driven tests):
go test -v ./cmd -run '^TestParseHostSpec$/host_with_port$'
- Repeat a flaky test deterministically:
go test -v ./internal/sshConn -run '^TestResolveHostPatternMatchWildcard$' -count=1
Because no project-specific linter config exists, use baseline Go checks:
- Format check and rewrite:
gofmt -w . - Vet all packages:
go vet ./... - Optional stronger check (if installed):
staticcheck ./...
If a change touches many files, run at least:
gofmt -w .go test -v ./...
If concurrency/networking code changes, also run:
go test -race ./...
- Prefer small, focused diffs.
- Do not introduce new dependencies unless clearly necessary.
- Preserve existing CLI behavior and command semantics.
- Keep public behavior aligned with
README.md. - Add or update tests when behavior changes.
These reflect patterns already used in this repository.
- Always use
gofmtformatting. - Keep package names short and lowercase; follow existing names (including
sshConn). - Keep functions cohesive and avoid deep nesting.
- Prefer early returns to reduce indentation.
- Group imports in three blocks when needed:
- Go standard library
- Third-party libraries
- Internal project imports (
github.com/ncode/pretty/...)
- Keep imports sorted as
gofmtoutputs. - Use import aliases only when needed for clarity or conflicts (for example
tea,homedir).
- Exported identifiers: PascalCase.
- Unexported identifiers: camelCase.
- Constants:
- exported: PascalCase if part of API
- internal/private: camelCase (
defaultPrompt,maxOutputLines)
- Test names:
TestXxxwith descriptive suffixes.
- Prefer concrete structs for domain state (
Manager,HostSpec,ResolvedHost). - Use pointers for shared/mutable state.
- Initialize slices/maps with capacity when size is known.
- Keep zero-value behavior sensible.
- In library/internal packages:
- return errors to caller
- wrap with context using
%wwhen rethrowing (fmt.Errorf("...: %w", err)).
- In CLI command execution paths (
cmd/), current pattern is:- print user-facing error
- exit non-zero (
os.Exit(1)).
- Avoid panics for expected runtime errors.
- Guard shared mutable state with
sync.Mutex/atomics as currently done. - Keep lock scope tight; avoid blocking operations while holding locks.
- For goroutines in tests/helpers, use
t.Cleanupto shut down resources.
- Prefer table-driven tests for parser/validation behavior.
- Use
t.Runwith stable, descriptive case names. - Use
t.Helper()in test helpers. - Use
t.Fatalffor fatal assertions; include expected vs got details. - Prefer deterministic tests; avoid sleeps unless absolutely required.
- Add comments for non-obvious logic, invariants, or protocol details.
- Do not add redundant comments that restate code.
- Keep exported APIs understandable from names and function signatures.
- Code is
gofmt-formatted. - Relevant package tests pass.
- Full
go test -v ./...passes for non-trivial changes. go test -race ./...run when touching concurrent code.README.mdupdated if CLI behavior or config format changed.
Checked paths:
.cursor/rules/.cursorrules.github/copilot-instructions.md
Current status in this repo: none of the above files exist.
If any are added later, treat their guidance as authoritative and merge it into this document.