sig

API surface extractor

Go Development GitHub

Extract public signatures, types, interfaces, and declarations as compact JSON - no implementation bodies. Use instead of reading entire files when you only need the API shape.

Features

  • Extracts function signatures, type/struct/interface definitions
  • Const/var blocks included
  • No implementation bodies - just the API surface
  • Supports Go (.go), TypeScript (.ts/.tsx), and C# (.cs)
  • Optional: include private/unexported with --all

Install

go install github.com/hegner123/sig@latest

The Problem: Reading an entire file just for its API

# You need to know what functions a file exports.
# Reading a 500-line file costs ~1,500 tokens.
# You only needed the 10 function signatures (~100 tokens).
#
# 93% of tokens wasted on implementation bodies.

Solution

$ sig --cli /path/to/server.go

Output

{"file":"server.go","package":"main","imports":["context","net/http","log/slog"],"types":[{"name":"Server","kind":"struct","fields":[{"name":"addr","type":"string"},{"name":"handler","type":"http.Handler"},{"name":"logger","type":"*slog.Logger"}]}],"functions":[{"name":"NewServer","signature":"func NewServer(addr string, handler http.Handler, logger *slog.Logger) *Server"},{"name":"Start","receiver":"*Server","signature":"func (s *Server) Start(ctx context.Context) error"},{"name":"Shutdown","receiver":"*Server","signature":"func (s *Server) Shutdown(ctx context.Context) error"}]}

Comparison

MetricValue
Token savings vs full file read~90%
Languages supportedGo, TypeScript, C#
ExtractsSignatures, types, interfaces, const/var