go-binary-size

go-binary-size is a skill for Claude Code from eduardo-sl/go-agent-skills. It costs 138 tokens per session (1,946 once invoked), scanned A, original, MIT.

A measurement-based guide for making compiled Go programs and their container images smaller. It examines the runtime, dependencies, compiler settings, embedded files, and other sources of size.

In plain words
What is it for?
It is for shrinking command-line tools, release binaries, and container images. It covers linker flags, inlining, CGO, build tags, embedded assets, and dependency analysis.
Why use it?
It replaces guesswork with before-and-after measurements, so you can see which changes actually save space. It also keeps size reductions tied to checks that the program still works.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions Claude Code.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is CGO_ENABLED=1 go build -trimpath -o /tmp/base ./cmd/app.

Part of the go-agent-skills plugin — 33 skills shipped together

Good fit It is for shrinking command-line tools, release binaries, and container images. It covers linker flags, inlining, CGO, build tags, embedded assets, and dependency analysis.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/eduardo-sl/go-agent-skills
agentmods
npx agentmods add skills/eduardo-sl/go-agent-skills/go-binary-size

Made for: Claude Code.

Or install go-agent-skills, the plugin that ships this one along with the rest of its 33 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for go-binary-size

README.md
[![agentmods](https://agentmods.dev/badge/skills/eduardo-sl/go-agent-skills/go-binary-size/github.svg)](https://agentmods.dev/skills/eduardo-sl/go-agent-skills/go-binary-size)
Your own site
<a href="https://agentmods.dev/skills/eduardo-sl/go-agent-skills/go-binary-size"><img src="https://agentmods.dev/badge/skills/eduardo-sl/go-agent-skills/go-binary-size/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for go-binary-size

Your own site · 80×15
<a href="https://agentmods.dev/skills/eduardo-sl/go-agent-skills/go-binary-size"><img src="https://agentmods.dev/badge/skills/eduardo-sl/go-agent-skills/go-binary-size.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 138 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,946 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Privilege Escalation · line 181
    Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
    Fix: Remove references to credential paths. Use environment variables or secrets managers. For docs, use placeholder paths (e.g., /path/to/config). Never load .env or token files in production code paths.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00138 $0.01946
Opus 5 $0.00069 $0.00973
Sonnet 5 $0.00028 $0.00389
Haiku 4.5 $0.00014 $0.00195

Measured 10d ago against content hash b096ec9e8d15, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

go-binary-size scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/(workflow)/go-binary-size/SKILL.md · 216 lines

How it starts

The opening of the file, as written. The whole thing — 216 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Go Binary Size

A stock Go binary carries the runtime, the garbage collector, full symbol and line tables, and every transitively reachable package. 8-15 MiB for a small CLI is normal. Most of it is removable, but only with measurement — guessing which dependency is heavy is almost always wrong.

Procedure

Never apply a flag without a before and after number.

  1. Build a baseline and record its size.
  2. Find where the bytes are.
  3. Apply one change class at a time, measuring after each.
  4. Verify the binary still runs and its tests still pass.
  5. Report the table of change → bytes saved → cost.

1. Measure First

# Baseline, reproducible
CGO_ENABLED=1 go build -trimpath -o /tmp/base ./cmd/app
ls -l /tmp/base

# Which packages and symbols cost the most
go tool nm -size -sort size /tmp/base | head -40

# Package-level attribution (third-party, more readable)
go install github.com/Zxilly/go-size-analyzer/cmd/gsa@latest
gsa --web /tmp/base

go version -m /tmp/app prints the module list and build settings baked into the binary — useful to confirm which flags a release actually used.

Also measure compressed size when the artifact ships in a container layer or a release archive. Stripping wins less after gzip; removing a dependency wins more.

gzip -c /tmp/base | wc -c

2. Strip Symbols and DWARF — the largest single win

go build -ldflags="-s -w" -trimpath -o /tmp/stripped ./cmd/app

Typically 25-35% off the raw size.

What this costs, precisely:

  • ✅ Panic messages and goroutine stack traces still work. The runtime uses its own pclntab, which -s -w does not remove.
  • dlv and gdb can no longer resolve source lines. Do not ship stripped binaries to an environment where you plan to attach a debugger.
  • ⚠️ Some profiling and crash-reporting tools that symbolise externally will degrade. net/http/pprof in-process is unaffected.

Keep an unstripped copy of every release build for post-mortem work.

Add -buildvcs=false when the VCS stamp is not needed. It saves little, but it also removes commit metadata from a distributed artifact.

Read the full file on GitHub · 216 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 216 lines · 138 tokens per session scan A b096ec9e8d15

Subscribe to this mod's changes

go-binary-size is a skill published in the GitHub repository eduardo-sl/go-agent-skills (71 stars, last pushed 23d ago), licensed MIT. It adds 138 tokens to every session and 1,946 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

go-containers

Go container optimization — scratch/distroless images, static binaries, CGO, ldflags, trimpath (846MB to 2.5MB). Use when working with Go containers or optimizing Go image sizes.

laurigates/claude-plugins · 47 tokens

go-deploy

Build and deploy Go applications — version detection, static binaries, CGO, workspaces, and Dockerfile patterns. Use when deploying a Go project, or when go.mod is detected.

nixopus/nixopus · 41 tokens

golang-k8s-agent

Use when building Go-based Kubernetes agents/controllers, reconcile loops, or cloud-native systems. Invoke for controller-runtime, CRDs, leader election, and Go concurrency.

Awish021/opencode · 39 tokens

docker-deploy

Build and deploy Go applications with Docker. Generates optimized multi-stage Dockerfiles, distroless images, docker-compose configs, and CI/CD pipelines. Use when dockerizing a Go app, optimizing image size, or setting up deployment. Triggers: "Dockerize my Go app", "Create a Dockerfile", "Deploy my Go service"…

daibang123a/golang-agent-skills · 87 tokens

docker-go

A command-line skill combining Docker and Go. Docker runs software in isolated containers, while Go is a programming language; the source does not describe the specific workflow this skill sets up.

openclaw-commons/openclaw-skill-commons · 0 tokens

golang-testing

Go testing best practices including table-driven tests, test helpers, benchmarking, race detection, coverage analysis, and integration testing patterns. Use when writing or improving Go tests.

affaan-m/ECC · 37 tokens