Skip to content

Go Tool Base

The Intelligent Lifecycle Framework for Go Applications

Command-line tools, long-running bots and daemons, and binaries that serve their own UI all need more than basic flag parsing. GTB works as a "batteries-included" micro-framework, providing a standardized foundation for all three, with built-in agentic workflows, hardware-backed credentials vaults, OpenTelemetry observability, and zero-config service management.

curl -sSL https://gtb.phpboyscout.uk/install.sh | bash
Go Tool Base System Architecture

Why GTB?

Before diving into code, we highly recommend reading our positioning guides to understand if GTB is the right fit for your next project:

Where the documentation lives

Four sections, each answering a different kind of question:

Overview

GTB is for three shapes of application, and a single binary can be all three:

  • Command-line tools that run once and exit.
  • Long-running processes, such as bots, workers and daemons, supervised for ordered start-up, health checks and graceful shutdown. A run without a terminal (systemd, a container, cron) starts without prompting anyone.
  • Binaries that serve their own local UI, such as a browser studio or a desktop app's backend.

GTB accelerates development by providing a standardized Dependency Injection (Props) container pre-wired with essential features. It includes multi-source configuration, automatic version checking, structured logging, and an AI service layer: allowing you to focus entirely on your unique business logic.

Key Features

πŸš€

CLI Code Scaffolding

Generate skeleton projects, manage commands, and scaffold flags in seconds with the GTB toolchain.

πŸ€–

AI Chat Provider

Integrated support for Claude, Gemini, and OpenAI APIs to power autonomous ReAct-style loops against your code.

πŸ”Œ

Model Context Protocol

Expose your CLI commands automatically as MCP tools for external AI agents over the stdio transport.

πŸ“Š

Telemetry & Logging

Built-in OpenTelemetry tracing spans and beautiful structured Charm log outputs for zero-config observability.

πŸ”

Credentials Vault

Native integration with macOS, Linux, and Windows keychains to enforce robust credential security.

πŸ“¦

Secure Auto-Updates

Zero-config version syncing, GPG manifest verification, and self-update capabilities via GitHub/GitLab releases.

Built-in Commands

A tool generated with GTB carries these commands by default, whichever shape it takes:

  • init - Initialize tool configuration and setup
  • version - Display version information and check for updates
  • update - Update the tool to the latest version
  • doctor - Diagnose configuration, credentials and the environment
  • docs - Interactive documentation browser with AI capabilities
  • mcp - Expose your tool's capabilities via the Model Context Protocol

Quick Start

package main

import (
    "embed"
    "os"

    "gitlab.com/phpboyscout/go-tool-base/pkg/cmd/root"
    "gitlab.com/phpboyscout/go/errorhandling"
    "gitlab.com/phpboyscout/go-tool-base/pkg/logger"
    "gitlab.com/phpboyscout/go-tool-base/pkg/props"
    "gitlab.com/phpboyscout/go-tool-base/pkg/version"
    "github.com/spf13/afero"
)

//go:embed assets/*
var assets embed.FS

func main() {
    l := logger.NewCharm(os.Stderr, logger.WithTimestamp(true))

    p := &props.Props{
        Tool: props.Tool{
            Name:        "mytool",
            Summary:     "My awesome CLI tool",
            Description: "A tool that does amazing things",
            ReleaseSource: props.ReleaseSource{
                Type:  "github",
                Owner: "myorg",
                Repo:  "mytool",
            },
        },
        Logger:  l,
        Assets:  props.NewAssets(props.AssetMap{"root": &assets}),
        FS:      afero.NewOsFs(),
        Version: version.NewInfo("1.0.0", "", ""),
    }
    p.ErrorHandler = errorhandling.New(logger.ToSlog(l), p.Tool.Help)

    rootCmd := root.NewCmdRoot(p)
    root.Execute(rootCmd, p)
}

CLI in Action

See how Go Tool Base builds and executes interactive lifecycle commands in real-time:

Ready to Build?

Whether you want to scaffold a new project in seconds or grow a command-line tool into a long-running service, Go Tool Base gives you the developer-focused lifecycle infrastructure out-of-the-box.

Further reading

The blog carries a curated route through this subject: Building a command-line tool in Go collects everything written about it, ordered so you can start at the beginning rather than newest-first.

Ask phpbotscout

phpbotscout

He answers questions about the projects over on the Discord, citing the docs where they already cover it, and offering to raise an issue where they don't. Bring a bug, an idea, or a questionable engineering decision.

Join the Discord