Creates executable Go scripts with shebang-like behavior. Use when the user wants Go scripts, mentions Go scripting, or needs executable .go files. If working in a Go project, do NOT use unless explicitly requested.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
npx agent-skills-cli listSkill Instructions
name: scripting-with-go description: Creates executable Go scripts with shebang-like behavior. Use when the user wants Go scripts, mentions Go scripting, or needs executable .go files. If working in a Go project, do NOT use unless explicitly requested. license: AGPL-3.0-or-later metadata: author: Amolith amolith@secluded.site
Create executable Go scripts using a shell trick (not a true shebang). Scripts run directly like ./script.go with full argument support.
Basic pattern
First line of any Go script (choose based on your shell):
// For dash (Debian/Ubuntu default):
//usr/bin/env go run "$0" "$@"; exit
// For bash/zsh (avoids gopls formatting complaints):
/**/usr/bin/env go run "$0" "$@"; exit;
Then chmod +x script.go and run ./script.go args.
Shell compatibility:
/**/syntax works in bash/zsh but NOT in dash//syntax works in dash but gopls will complain about formatting- Check your
/bin/sh:ls -l /bin/sh - Use
//usr/bin/env goto find go in PATH - Use
//usr/local/go/bin/gofor absolute path
How it works
- OS tries to execute
./script.goas binary - Fails with ENOEXEC (not a binary)
- OS falls back to
/bin/sh - Shell runs first line: compiles and executes the script
$0= script path,$@= all argumentsexit(orexit;) prevents shell from interpreting remaining Go code- Shell normalizes
//pathto/pathor/**/pathto/path
Complete example
//usr/bin/env go run "$0" "$@"; exit
package main
import (
"fmt"
"os"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: ./script.go <name>")
os.Exit(1)
}
fmt.Printf("Hello, %s!\n", os.Args[1])
}
When to use
Good for:
- Long-lived automation needing stability (Go 1.x compatibility guarantee)
- Cross-platform scripts
- Corporate environments
- Scripts that may grow into programs
- Avoiding dependency management hell
Avoid for:
- Simple one-liners
- Systems without Go
- Throwaway scripts
Common patterns
CLI flags
//usr/bin/env go run "$0" "$@"; exit
package main
import (
"flag"
"fmt"
)
func main() {
verbose := flag.Bool("v", false, "verbose output")
flag.Parse()
fmt.Printf("Verbose: %v, Args: %v\n", *verbose, flag.Args())
}
stdin
//usr/bin/env go run "$0" "$@"; exit
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
fmt.Println("Got:", scanner.Text())
}
}
File operations
//usr/bin/env go run "$0" "$@"; exit
package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
fmt.Println(path)
}
return nil
})
}
Notes
- Using
envfindsgoin PATH, making scripts more portable - Semicolon required in
exit;with/**/syntax (but not with//) - Avoid dependencies for maximum compatibility
- Slower startup than interpreted languages (compilation time)
More by jeninh
View allStyles UI with the Hack Club aesthetic using hack.css. Opt-in only—use when user confirms they want Hack Club styling after being asked "Would you like to use the Hack Club UI skill?"
Creates tasks in Lunatask for todos, reminders, deferred work, and handoffs. Use when the user wants to capture something for later, whether for themselves or for a future agent session.
Spawns subagents with configurable tool access that return just the answers without flooding your context. Use for summarizing extensive git history, comparing across multiple repositories in parallel, or processing large diffs/logs.
Spawns a focused subagent to query language/framework documentation. Use for complex questions requiring exploration across multiple symbols, external library APIs, or understanding how to combine types from different packages. Currently supports Go; more doc sets may be added later.
