jenkins-cli
CLAUDE.md98 starsChanged 8 months agoMITView on GitHub
This is the master agent instruction file for this repository. Keep repository policy here. AGENTS.md exists only as a Codex compatibility shim and should contain only Codex-specific notes. This is jk, a GitHub CLI–style interface for Jenkins controllers written in Go 1.26+. Factory Pattern: pkg/cmdutil/Factory provides dependency injection for all commands—IOStreams, Config loader, and JenkinsClient factory. Jenkins Client: Created per-context via internal/jenkins/Client. Auto-handles CSRF crumbs, TLS/proxy settings, and capability detection via /jk/api/status. Command Execution Flow:
The file
We split this CLAUDE.md into the rules it gives an agent
10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 28
Run make build and make test before commit.
- Very specific: line 29
Run make e2e when Jenkins-facing behavior changes and Docker is available.
- Very specific: line 30
Run gofmt -w on touched Go packages.
- Very specific: line 80
Commit messages: Use conventional commits (feat:, fix:, deps:, ci:, chore:)
- Very specific: line 81
Formatting: Run gofmt -w on touched packages
- Very specific: line 82
Documentation: Update README.md and docs/spec.md for user-facing changes
- Very specific: line 83
New directories: Update docs/spec.md before adding top-level directories
- Very specific: line 89
Keep CHANGELOG.md and skill/plugin metadata on one version in the release commit.
- Distinctive: line 94
Avoid adding new top-level directories without updating the docs first.
- Very specific: line 98
When automating with jk:
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 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
CLAUDE.md
This is the master agent instruction file for this repository. Keep repository policy here. AGENTS.md exists only as a Codex compatibility shim and should contain only Codex-specific notes.
Build & Test Commands
make build # Build binary to ./bin/jk (injects version via ldflags)
make test # Run unit tests (228+ tests)
make lint # Run golangci-lint
make e2e # Run end-to-end tests (requires Docker)
make fmt # Format code with gofmt
# Run a single test
go test -run TestFunctionName ./path/to/package
# Skip e2e tests during unit testing
JK_E2E_DISABLE=1 make test
# E2E with Colima on macOS (if Docker is unreachable)
colima start --network-address
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
make e2eRequired Checks
- Run
make buildandmake testbefore commit. - Run
make e2ewhen Jenkins-facing behavior changes and Docker is available. - Run
gofmt -won touched Go packages.
Architecture
This is jk, a GitHub CLI–style interface for Jenkins controllers written in Go 1.26+.
Code Layout (mirrors gh CLI)
cmd/jk/ → Entry point only; calls internal/jkcmd.Main()
internal/
jkcmd/ → CLI initialization and factory wiring
jenkins/ → HTTP client (go-resty), CSRF crumb handling, capability detection
config/ → YAML configuration (<UserConfigDir>/jk/config.yaml)
secret/ → OS keyring token storage (fallback: encrypted file)
build/ → Version info (injected via ldflags)
log/ → Structured logging (zerolog)
pkg/
cmd/<command>/ → Cobra command implementations (auth, run, job, artifact, etc.)
cmd/shared/ → Shared helpers (output formatting, client resolution)
cmdutil/ → Factory pattern, error handling, exit codes
iostreams/ → I/O abstraction (TTY detection, color, progress)
test/e2e/ → End-to-end tests using testcontainers-goKey Patterns
Factory Pattern: pkg/cmdutil/Factory provides dependency injection for all commands—IOStreams, Config loader, and JenkinsClient factory.
Jenkins Client: Created per-context via internal/jenkins/Client. Auto-handles CSRF crumbs, TLS/proxy settings, and capability detection via /jk/api/status.
Command Execution Flow:
main.go → jkcmd.Main() → root.NewCmdRoot(factory) → Cobra Execute()
↓
pkg/cmd/<command>/*.go
↓
shared.JenkinsClient(cmd, factory)
↓
jenkins.Client.Do(request)Multi-Context Support
- Contexts stored in
<UserConfigDir>/jk/config.yaml(~/.config/jkon Linux,~/Library/Application Support/jkon macOS,%AppData%\jkon Windows) - Tokens in OS keyring (macOS Keychain, Linux secretservice, Windows credential manager)
- Resolution:
--contextflag →JK_CONTEXTenv → active context in config
Conventions
- Commit messages: Use conventional commits (
feat:,fix:,deps:,ci:,chore:) - Formatting: Run
gofmt -won touched packages - Documentation: Update
README.mdanddocs/spec.mdfor user-facing changes - New directories: Update
docs/spec.mdbefore adding top-level directories
Release Contract
- Release from
mainonly through theRelease requestGitHub Actions workflow (workflow_dispatchwith versionX.Y.Z) or./scripts/release.sh X.Y.Z, and the resulting release PR; do not create manual tags or GitHub releases. - A push to
mainupdates the AvivSinai marketplace immediately for thejkskill. - Keep
CHANGELOG.mdand skill/plugin metadata on one version in the release commit; after the release PR merges, CI validates the merged commit, creates the tag, publishes GitHub/Homebrew artifacts, and uses the committed changelog entry as the GitHub release notes.
Documentation Expectations
- User-facing changes should update
README.mdand, when relevant,docs/spec.mdordocs/api.md. - Avoid adding new top-level directories without updating the docs first.
Agent Discovery Patterns
When automating with jk:
jk search --job-glob '*pattern*' --jsonfor cross-folder job discoveryjk run ls <job> --filter result=SUCCESS --since 7d --jsonfor filtered run queriesjk run params <job>to inspect parameter metadata before triggering buildsjk help --jsonfor programmatic command enumeration
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.

