| name | bob-generate-overview |
| description | Generate a stylized, self-contained HTML report for any Go codebase element โ functions, packages, interfaces, structs, handlers, CLI commands, and more |
| user-invocable | true |
| category | documentation |
Generate Overview โ HTML Report
You produce a single self-contained HTML file describing a Go codebase element. The report
is modern, clean, and interactive โ no external dependencies. You detect what the user is
pointing at, choose the right report template, research thoroughly, then generate.
Phase 1: IDENTIFY TARGET
Ask the user what they want documented:
What should I generate a report for? Point me at something:
a function, package, file, struct, interface, directory, handler, CLI command, etc.
The user may give you a function name, file path, package path, or description. Use your
tools to resolve it to a concrete code element.
Detect the target type by examining what the user pointed at:
| Target Type | How to Detect |
|---|
| Function | User names a function; or you resolve to a func declaration |
| Interface | User names an interface; resolves to type X interface |
| Struct | User names a struct; resolves to type X struct |
| Package | User names a package or directory containing .go files with package declarations |
| File | User gives a specific .go file path |
| Directory | Path contains mixed files (not a single Go package) |
| HTTP Handler | Function signature matches (w http.ResponseWriter, r *http.Request) or returns http.Handler; or is registered with a router |
| CLI Command | Uses cobra.Command, flag.FlagSet, os.Args, or similar CLI framework patterns |
| Middleware | Function that wraps/returns http.Handler or http.HandlerFunc; or follows func(next http.Handler) http.Handler pattern |
| Config/Constants | User points at a const or var block, or a config struct |
| Protobuf/gRPC | .proto file, or Go file with generated gRPC service stubs |
| Makefile/Build | Makefile, Taskfile.yml, .goreleaser.yml, or similar |
Tell the user what you detected:
I see this is a [target type]: [name] in [location].
Generating report...
If ambiguous, ask. Do NOT ask for a "depth level" โ the target type determines the report format.
Phase 2: RESEARCH
Gather everything needed for the report. Run these in parallel where possible.
2a. Read the target
- Read the target code thoroughly
- For functions: read the full function body and its doc comment
- For packages: read all exported types, functions, and their doc comments
- For files: read the entire file
- For interfaces: find all implementations via grep
2b. Find context
- Who calls this? (
grep for usage sites)
- What does this call? (read function bodies for outbound calls)
- Are there tests? Read relevant test files
- Any spec documents? (SPECS.md, NOTES.md, CLAUDE.md in the package)
2c. Collect metadata
- File path and line numbers for all code elements
- Package import path
- Git blame for last-modified info if relevant
Phase 3: GENERATE HTML
Generate a single self-contained HTML file. All CSS and JS must be inline. No external
resources, CDNs, or dependencies. The file must look great when opened in any browser.
Global HTML Design System
Every report shares these design properties:
DESIGN TOKENS:
- Font stack: system-ui, -apple-system, "Segoe UI", sans-serif
- Mono font: "SF Mono", "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, monospace
- Base size: 15px body, 13px code
- Max width: 1200px centered, with sidebar where applicable
- Border radius: 8px cards, 6px code blocks, 4px inline code
- Shadows: subtle, using rgba(0,0,0,0.06) for light, rgba(0,0,0,0.3) for dark
COLOR PALETTE (light mode):
- Background: #ffffff page, #f8f9fb cards/sidebar, #f1f3f5 code blocks
- Text: #1a1a2e primary, #495057 secondary, #868e96 muted
- Accent: #4263eb primary actions/links, #748ffc hover
- Borders: #e9ecef default, #dee2e6 heavy
- Syntax: #d73a49 keywords, #6f42c1 types, #005cc5 functions, #032f62 strings, #6a737d comments
COLOR PALETTE (dark mode):
- Background: #1a1b26 page, #24283b cards/sidebar, #1e2030 code blocks
- Text: #c0caf5 primary, #9aa5ce secondary, #565f89 muted
- Accent: #7aa2f7 primary, #89b4fa hover
- Borders: #3b4261 default, #414868 heavy
- Syntax: #f7768e keywords, #bb9af7 types, #7aa2f7 functions, #9ece6a strings, #565f89 comments
INTERACTIVE FEATURES (include in every report):
- Dark/light mode toggle (top-right, respects prefers-color-scheme)
- Collapsible sections via <details>/<summary> with smooth animation
- Smooth scroll to anchors
- Copy button on all code blocks
- Keyboard shortcut: 't' to toggle theme, '/' to focus search (if search exists)
Report Templates by Target Type
IMPORTANT โ Source links everywhere: Every file path, function name, type name, line
number reference, and declaration in the report MUST be a clickable vscode://file/ link
(see the Source Links section below for format and styling). When a template says
"file:line link" or "linked" or "with line number", it means a vscode://file/ source link.
Do not render any file:line reference as plain text.
FUNCTION Report
A line-by-line annotated walkthrough of a single function.
Layout: Single column, no sidebar.
Sections:
- Header โ Function signature in a large code block. Doc comment rendered below.
- At a Glance โ Card grid:
- Package & file location (with line number)
- Receiver type (if method)
- Parameters table (name, type, purpose)
- Return values table (type, purpose, error conditions)
- Annotated Source โ The core of this report:
- Show the full function source with line numbers
- Each logical block gets a margin annotation โ a short callout on the right side
explaining what that block does and why
- Group lines into logical blocks (setup, validation, core logic, error handling, cleanup)
- Use colored left-border strips to distinguish block types:
- Blue: setup/initialization
- Green: core logic / happy path
- Yellow: validation / guards
- Red: error handling
- Gray: cleanup / defer
- For complex expressions, add inline tooltips or expandable explanations
- Call Graph โ What this function calls (as a simple list with file:line links).
What calls this function (usage sites found via grep).
- Error Paths โ If the function returns errors, list each error return with:
- The condition that triggers it
- The error value/message
- Line number link
- Related โ Links to: test functions, related functions in same package, interface
it implements (if method).
INTERFACE Report
Layout: Two-column โ main content + right sidebar listing all implementors.
Sections:
- Header โ Interface name, package, doc comment.
- Contract โ Full interface definition in a code block.
- Method Catalog โ For each method:
- Signature
- Purpose (from doc comments or inferred)
- Parameters and return values
- Behavioral contract / expectations
- Implementors โ Each known implementation:
- Type name and package (linked)
- Which methods it implements (checkmarks in a matrix if >3 methods)
- Brief description of how this implementation differs
- Key implementation detail or trade-off
- Usage Patterns โ How callers typically use this interface. Code snippets from real usage.
- Sidebar โ Sticky list of implementors with jump links.
STRUCT Report
Layout: Single column with collapsible sections.
Sections:
- Header โ Struct name, package, doc comment.
- Field Reference โ Table:
- Field name | Type | JSON/YAML tag | Purpose
- Group by concern if >8 fields (use sub-headers)
- Highlight unexported fields with a subtle indicator
- Constructors โ Functions that return this struct (
NewX, MakeX, etc.):
- Signature, doc comment, which fields they set
- Methods โ Grouped by concern:
- For each: signature, one-line purpose, receiver type (pointer vs value)
- Expandable: full doc comment and parameter details
- Used By โ Where this struct is instantiated or referenced.
Top 10 usage sites with file:line links.
- Implements โ Interfaces this struct satisfies (if any).
PACKAGE Report
Layout: Two-column โ main content + left sidebar with navigation.
Sections:
- Header โ Package name, import path, package doc comment.
- Overview โ 3-5 sentence summary of what this package does and why it exists.
- Sidebar Navigation โ Sticky nav listing all sections with counts:
- Types (N) / Functions (N) / Constants (N) / Variables (N)
- Architecture โ ASCII or text description of how the major types relate.
Show dependency flow between internal components.
- Public API โ Grouped catalog:
- Interfaces โ name, one-line purpose, method count
- Structs โ name, one-line purpose, field count
- Functions โ name, signature, one-line purpose
- Constants & Variables โ grouped by block, with values
Each item is collapsible to show full details.
- Internal Design โ Key unexported types and helpers that a contributor should know about.
- Dependencies โ What this package imports (grouped: stdlib, internal, external).
What imports this package.
- Testing โ Test file overview. How to run tests. Notable test helpers.
FILE Report
Layout: Two-column โ main content + right sidebar with structure outline.
Sections:
- Header โ File path, package, last modified info.
- Sidebar โ Sticky outline of every declaration in the file:
- type, func, const, var โ with line numbers
- Click to scroll to that section
- Search/filter box at top of sidebar
- File Overview โ What this file is responsible for. Inferred from its contents and
the package context.
- Declarations โ Walk through the file top-to-bottom:
- Each declaration gets a card:
- Name and kind (type/func/const/var)
- Line range
- Doc comment
- Syntax-highlighted source (collapsible for long items)
- Annotations for non-obvious logic
- Imports โ What this file imports, grouped and annotated with why each is needed.
- Cross-References โ Other files in the package that reference declarations in this file.
DIRECTORY Report (non-package)
Layout: Single column with file tree.
Sections:
- Header โ Directory path, total file count, language breakdown.
- File Tree โ Interactive tree view:
- Each file gets a one-line purpose annotation
- Directories are collapsible
- Entry points highlighted with a marker
- Test files visually distinguished
- Package Map โ If directory contains multiple Go packages, show each with:
- Package name, import path, purpose
- Key exported symbols
- Dependency Flow โ How packages in this directory depend on each other.
- Entry Points โ Main functions, init functions, handler registrations.
- Configuration โ Config files present (go.mod, Makefile, Dockerfile, etc.)
with brief description of each.
HTTP HANDLER Report
Layout: Single column, visually structured like API documentation.
Sections:
- Header โ Handler function name, route pattern (if discoverable), HTTP method.
- Endpoint Card โ Prominent card:
METHOD /path/to/endpoint
- Brief description
- Middleware Chain โ Ordered list of middleware applied to this handler:
- Each middleware: name, what it does, what it adds to context
- Visual pipeline:
Request โ Auth โ RateLimit โ Logger โ [Handler] โ Response
- Request โ What this handler expects:
- URL parameters
- Query parameters
- Request body schema (struct fields if JSON-decoded)
- Required headers
- Response โ What this handler returns:
- Success response (status code, body shape)
- Error responses (each error status code, condition, body)
- Annotated Source โ Same as Function report's annotated source section.
- Auth & Permissions โ What auth is required (inferred from middleware or code).
CLI COMMAND Report
Layout: Single column, styled like a modern man page.
Sections:
- Header โ Command name, one-line description.
- Synopsis โ Usage string in a code block.
- Description โ Full description from the command's
Long field or doc comment.
- Flags โ Table:
- Flag | Short | Type | Default | Env Var | Description
- Required flags highlighted
- Subcommands โ If this is a parent command:
- Each subcommand: name, one-line description
- Collapsible to show that subcommand's flags
- Environment Variables โ Any env vars read by this command.
- Examples โ Usage examples from the command definition or tests.
- Source โ Link to the file:line where the command is defined.
MIDDLEWARE Report
Layout: Single column with a visual flow diagram.
Sections:
- Header โ Middleware function name, package.
- Flow Diagram โ Visual representation:
โโโโโโโโโโโโโโโ
โ Request โ
โโโโโโโโฌโโโโโโโ
โผ
โโโโโโโโโโโโโโโ
โ [Before] โ โ what this middleware does before calling next
โ Auth check โ
โโโโโโโโฌโโโโโโโ
โผ
โโโโโโโโโโโโโโโ
โ next() โ โ inner handler
โโโโโโโโฌโโโโโโโ
โผ
โโโโโโโโโโโโโโโ
โ [After] โ โ what this middleware does after (if anything)
โ Log access โ
โโโโโโโโฌโโโโโโโ
โผ
โโโโโโโโโโโโโโโ
โ Response โ
โโโโโโโโโโโโโโโ
Rendered as inline SVG.
- Context Injection โ What this middleware adds to
context.Context:
- Key, value type, how to retrieve it downstream
- Short-Circuit Conditions โ When does this middleware stop the chain:
- Condition, HTTP status returned, error body
- Ordering Dependencies โ Must come before/after other middleware. Why.
- Annotated Source โ Same style as Function report.
CONFIG / CONSTANTS Report
Layout: Single column, styled as a reference card.
Sections:
- Header โ Block location, purpose.
- Reference Table โ For each constant/variable:
- Name | Type | Value | Used By | Description
- "Used By" links to call sites
- Sortable columns (JS)
- Grouping โ If constants use
iota, show the enumeration with meaning of each value.
- Configuration Map โ For config structs:
- Field | Type | Default | Env Var | CLI Flag | Description
- Mark required vs optional
- Show validation rules if present
- Impact โ What changes when you modify each value. Brief notes per item.
PROTOBUF / gRPC SERVICE Report
Layout: Two-column โ methods list in sidebar, details in main.
Sections:
- Header โ Service name, proto file, package.
- Sidebar โ List of all RPC methods with streaming indicators:
โ unary
โโ server streaming
โโ bidirectional
- Service Overview โ What this service does, who calls it.
- Methods โ For each RPC:
- Method name, streaming type
- Request message (fields table)
- Response message (fields table)
- Error codes returned
- Messages โ All message types used by this service:
- Field number, name, type, description
- Nested messages shown indented
- Generated Code โ Where the generated Go code lives, key files.
MAKEFILE / BUILD CONFIG Report
Layout: Single column with visual dependency graph.
Sections:
- Header โ File name, build system type.
- Target Graph โ Visual DAG of target dependencies (inline SVG):
- Commonly-used targets highlighted
- Default target marked
- Target Reference โ For each target:
- Name, dependencies, description (from comments)
- Commands it runs (collapsible)
- Variables that affect it
- Variables โ All variables defined:
- Name, default value, description, overridable?
- Environment โ Env vars that affect the build.
- Quick Reference โ Top 5 most useful commands in a copy-friendly card.
Source Links
All "jump to source" references in the report must be clickable links that open the file
in the user's editor. Use absolute file paths resolved from the working directory.
Link format: Use vscode://file/{absolute_path}:{line}:{column} URIs.
- Resolve all paths to absolute (e.g.
/Users/joe/dev/project/pkg/auth/handler.go:42)
- Line numbers are 1-based
- Column defaults to 1 if not relevant
- Example:
vscode://file///Users/joe/dev/project/pkg/auth/handler.go:42:1
Where to add source links:
- Every file path reference (e.g.
pkg/auth/handler.go:42 โ clickable)
- Function names in call graphs and "Used By" sections
- Struct/interface names in "Implements" and "Implementors" sections
- Import paths that resolve to local packages
- Sidebar entries in File and Package reports
- Every declaration card's line range
- "Used By" and "Callers" entries
- Error path line references in Function reports
Styling for source links:
a.src-link {
font-family: var(--mono);
font-size: 0.85em;
color: var(--accent);
text-decoration: none;
border-bottom: 1px dashed var(--accent);
opacity: 0.8;
transition: opacity 0.15s;
}
a.src-link:hover {
opacity: 1;
border-bottom-style: solid;
}
Display the relative path as the link text (for readability) but use the absolute
path in the href URI. Add a small external-link icon (inline SVG, 12px) after each
source link to signal it opens an editor.
Phase 4: OUTPUT
-
Write the HTML file to the current directory:
- Filename:
<target-name>-report.html (kebab-case)
- Example:
rate-limiter-report.html, auth-middleware-report.html
-
Open the report in the default browser:
open <filename>
xdg-open <filename>
-
Tell the user:
Report written to <filename> and opened in your browser.
-
Do NOT print the HTML to the conversation. It's too long and not useful in terminal.
HTML Quality Checklist
Before writing the file, verify your HTML meets these standards:
Syntax Highlighting Rules
Apply these CSS classes to Go code tokens. Do NOT use an external library โ apply classes
during generation based on Go syntax:
| Token Type | CSS Class | Light Color | Dark Color |
|---|
Keyword (func, type, if, return, etc.) | .kw | #d73a49 | #f7768e |
Type name (string, int, error, custom) | .typ | #6f42c1 | #bb9af7 |
| Function name (in calls and declarations) | .fn | #005cc5 | #7aa2f7 |
| String literal | .str | #032f62 | #9ece6a |
| Number literal | .num | #005cc5 | #ff9e64 |
| Comment | .cmt | #6a737d | #565f89 |
| Operator / punctuation | .op | #d73a49 | #89ddff |
| Package / import path | .pkg | #e36209 | #ff9e64 |
Apply highlighting by wrapping tokens in <span class="XX">. For the annotated source
sections, combine with line-number gutters and annotation margins.