| name | golang-script-developer |
| version | 1.0.0 |
| description | Write production-ready Go CLI tools, automation programs, and batch file processors with
idiomatic Go patterns — Go modules layout, the standard library flag package by default
(or cobra/urfave-cli for complex CLIs), structured logging via log/slog (Go 1.21+),
error wrapping with fmt.Errorf %w plus errors.Is/errors.As, context.Context for
cancellation and timeouts, signal.NotifyContext for graceful SIGINT/SIGTERM, distinct
exit codes per failure mode, embedded assets via //go:embed, race-detector-clean
concurrency with errgroup, and cross-platform / cross-compile support (GOOS/GOARCH) for
Linux, macOS, Windows. Targets Go 1.22 and above. Use this skill whenever the user asks
to create a Go / Golang script, .go program, single-binary CLI tool, automation, batch
processor, or data pipeline — including casual phrasings like 'write a go program that
...', 'automate this in golang', 'make me a go CLI', or 'I need a single-binary tool'.
Also use when reviewing or hardening an existing Go program.
|
| license | MIT |
| compatibility | claude-code opencode |
| allowed-tools | ["Read","Write","Edit","Grep","Glob","Bash"] |
| metadata | {"author":"MKAbuMattar","requirements":"Go 1.22 or newer on Linux, macOS, or Windows. Cross-compiles to any GOOS/GOARCH the toolchain supports."} |
Go Script Developer
Production-ready Go. Modules layout + flag/cobra + log/slog + error wrapping with %w + context-aware cancellation + signal.NotifyContext + typed exit errors + errgroup concurrency + cross-compile single binaries.
When to use
- The user asks for any
.go program, Go CLI, automation, single-binary tool, or batch processor.
- The user wants to harden, refactor, or review an existing Go program.
- A task chain ends in "and put it in a Go program".
Skip this skill for: web servers (different shape — frameworks like net/http + chi), full applications with persistent storage (database-backed apps need their own architecture), or non-Go scripts (use the matching language skill).
Required structure
Every program you write starts from this skeleton. Do not omit the typed exit error, signal.NotifyContext, or the separation between main and run(ctx, args).
package main
import (
"context"
"errors"
"flag"
"fmt"
"log/slog"
"os"
"os/signal"
"syscall"
)
const (
exitOK = 0; exitGeneric = 1; exitUsage = 2; exitInput = 3
exitInterrupt = 130
)
type exitError struct{ code int; err error }
func (e *exitError) Error() string { return e.err.Error() }
func Unwrap() { e.err }
args {
input
verbose
}
(args, ) {
fs := flag.NewFlagSet(, flag.ContinueOnError)
fs.SetOutput(os.Stderr)
a args
fs.BoolVar(&a.verbose, , , )
err := fs.Parse(os.Args[:]); err != { a, err }
fs.NArg() != {
a, &exitError{code: exitUsage, err: fmt.Errorf()}
}
a.input = fs.Arg()
a,
}
{
slog.Info(, , a.input)
}
{
a, err := parseArgs()
err != {
errors.Is(err, flag.ErrHelp) { os.Exit(exitOK) }
ee *exitError
errors.As(err, &ee) { fmt.Fprintln(os.Stderr, , err); os.Exit(ee.code) }
fmt.Fprintln(os.Stderr, , err); os.Exit(exitUsage)
}
level := slog.LevelInfo
a.verbose { level = slog.LevelDebug }
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: level})))
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
stop()
err := run(ctx, a); err != {
ee *exitError
errors.As(err, &ee) { slog.Error(ee.Error()); os.Exit(ee.code) }
errors.Is(err, context.Canceled) { slog.Info(); os.Exit(exitInterrupt) }
slog.Error(, , err); os.Exit(exitGeneric)
}
}