{"id":47637505,"url":"https://github.com/justinstimatze/defn","last_synced_at":"2026-04-16T09:07:17.981Z","repository":{"id":346246559,"uuid":"1188657891","full_name":"justinstimatze/defn","owner":"justinstimatze","description":"AI-native code database for Go. Navigate, edit, and understand Go code by structure instead of by file.","archived":false,"fork":false,"pushed_at":"2026-03-28T06:04:23.000Z","size":94,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-02T08:26:47.855Z","etag":null,"topics":["ai","ai-coding","claude-code","code-database","developer-tools","dolt","go","golang","mcp","python","rust","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/justinstimatze/defn","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justinstimatze.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-22T12:03:11.000Z","updated_at":"2026-03-31T22:43:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/justinstimatze/defn","commit_stats":null,"previous_names":["justinstimatze/defn"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/justinstimatze/defn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinstimatze%2Fdefn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinstimatze%2Fdefn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinstimatze%2Fdefn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinstimatze%2Fdefn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinstimatze","download_url":"https://codeload.github.com/justinstimatze/defn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinstimatze%2Fdefn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31501903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-coding","claude-code","code-database","developer-tools","dolt","go","golang","mcp","python","rust","typescript"],"created_at":"2026-04-02T00:24:09.777Z","updated_at":"2026-04-07T06:01:01.410Z","avatar_url":"https://github.com/justinstimatze.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# defn — code in high definition\n\n[![CI](https://github.com/justinstimatze/defn/actions/workflows/ci.yml/badge.svg)](https://github.com/justinstimatze/defn/actions/workflows/ci.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/justinstimatze/defn)](https://goreportcard.com/report/github.com/justinstimatze/defn)\n[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Release](https://img.shields.io/github/v/release/justinstimatze/defn)](https://github.com/justinstimatze/defn/releases)\n\n**Your Go code lives in two places: files and a graph.** Both are complete, lossless representations of the same code — kept in sync automatically. Files work with every tool in the Go ecosystem. The graph adds structure: every function, method, type, and constant is a node; every call, reference, and interface implementation is an edge.\n\nEdit through defn or edit files directly. Either side auto-syncs to the other. Either can recover the other.\n\n**\"What breaks if I change this function?\"** Tested on [gin-gonic/gin](https://github.com/gin-gonic/gin) (24K lines, 1,580 definitions):\n\n\u003e **Without defn:** grep → read 5 files → scroll → guess\n\u003e 9 calls | 144K tokens | 45s | found 19 of 21 callers | no transitives | no test count\n\n\u003e **With defn:** `code(op:\"impact\", name:\"Render\")`\n\u003e **2 calls | 51K tokens | 12s | 33 callers | 341 transitive | 238 tests** — including interface dispatch\n\n## What makes this different\n\n**Files don't know about each other.** grep finds text matches, not callers. Reading `context.go` doesn't tell you that `responseWriter` satisfies `ResponseWriter`, or that changing `WriteHeader` breaks 238 tests through interface dispatch. That information exists in the type system but dies when you close your editor.\n\n**defn makes it permanent.** It parses your code with `go/types` (the same type checker gopls uses) and stores the result in [Dolt](https://www.dolthub.com/) — a SQL database with git semantics. The reference graph persists across sessions, includes interface satisfaction, and is queryable:\n\n```sql\n-- Who calls Render and has no tests?\nSELECT d.name FROM definitions d\nJOIN `references` r ON r.from_def = d.id\nWHERE r.to_def = (SELECT id FROM definitions WHERE name = 'Render' AND receiver = '*Context')\nAND d.test = FALSE\nAND NOT EXISTS (\n  SELECT 1 FROM `references` r2\n  JOIN definitions t ON t.id = r2.from_def AND t.test = TRUE\n  WHERE r2.to_def = d.id\n)\n```\n\n## Setup\n\n```bash\ngo install github.com/justinstimatze/defn/cmd/defn@latest\ngo install golang.org/x/tools/cmd/goimports@latest\n\ncd your-go-project\ndefn init . --server    # recommended: starts Dolt server for multi-agent\ndefn init .             # or: embedded mode, no server needed\n```\n\nThen start Claude Code or Codex and ask:\n\n```\n\"What's the blast radius of changing the Render function?\"\n\"Which functions have no test coverage?\"\n\"Find all functions that handle authentication\"\n```\n\nTo remove everything: `defn clean`\n\nRequires Go 1.26+, CGO, and `goimports`. Binary is ~140MB due to embedded Dolt engine.\n\n**macOS:** `brew install icu4c` then:\n```bash\nexport CGO_CFLAGS=\"-I$(brew --prefix icu4c)/include\"\nexport CGO_LDFLAGS=\"-L$(brew --prefix icu4c)/lib\"\ngo install github.com/justinstimatze/defn/cmd/defn@latest\n```\n\n## How it works\n\nOne MCP tool — `code` — with an `op` field. Your AI agent calls it naturally:\n\n| What you ask | What defn does |\n|---|---|\n| \"Show me Render\" | `code(op:\"read\", name:\"Render\")` — full source, disambiguated by blast radius |\n| \"What depends on this?\" | `code(op:\"impact\", name:\"X\")` — callers, transitives, test coverage, interface dispatch |\n| \"Change 3 lines in this function\" | `code(op:\"edit\", name:\"X\", old_fragment:\"...\", new_fragment:\"...\")` — no need to provide the whole body |\n| \"Rewrite this function\" | `code(op:\"edit\", name:\"X\", new_body:\"...\")` — full replacement, auto-emits + builds |\n| \"What's in this file?\" | `code(op:\"overview\", file:\"server.go\")` — all definitions with caller/callee counts |\n| \"Rename across the codebase\" | `code(op:\"rename\", old_name:\"X\", new_name:\"Y\")` — updates definition + all callers |\n| \"Run only affected tests\" | `code(op:\"test\", name:\"X\")` — via reference graph, not `go test ./...` |\n| \"Simulate a change\" | `code(op:\"simulate\", mutations:[...])` — throwaway branch, ripple report, discard |\n\n\u003cdetails\u003e\n\u003csummary\u003eAll operations\u003c/summary\u003e\n\n| Op | What it does | Key params |\n|---|---|---|\n| `read` | Full source of a definition | `name` or `file:line` |\n| `search` | Find by name pattern (%) or body text | `pattern` |\n| `impact` | Blast radius, callers, test coverage | `name` |\n| `explain` | Signature + callers + callees + tests | `name` |\n| `overview` | All definitions in a file with relationships | `file` |\n| `similar` | Find definitions with similar signatures | `name` |\n| `untested` | Definitions without test coverage | — |\n| `edit` | Full body replace, OR fragment replace via `old_fragment`+`new_fragment` | `name` |\n| `insert` | Insert code after an anchor string | `name`, `after`, `body` |\n| `create` | Create (infers name/kind from body) | `body`, optional `module` |\n| `delete` | Remove + clean up references | `name` |\n| `rename` | Rename + update callers (AST-based, preserves comments) | `old_name`, `new_name` |\n| `move` | Move to another module | `name`, `module` |\n| `test` | Run only affected tests | `name` |\n| `simulate` | Throwaway branch, apply mutations, ripple report | `mutations` |\n| `apply` | Batch operations (transactional) | `operations` |\n| `diff` | Uncommitted changes | — |\n| `history` | Commit history for a definition | `name` |\n| `find` | Definition at a file:line | `file`, `line` |\n| `sync` | Re-ingest after file edits | — |\n| `query` | Read-only SQL | `sql` |\n| `test-coverage` | Test names covering a definition | `name` |\n| `batch-impact` | Combined blast radius for multiple definitions | `names` |\n| `file-defs` | Map file path to definitions | `file` |\n\n\u003c/details\u003e\n\nName-based ops accept `file:line` paths and `Receiver.Method` syntax (`Context.Render`, `(*Router).Handle`).\n\n## Versioning\n\nDolt gives git semantics on SQL data. Branch, merge, diff, commit — natively, on definitions.\n\n```bash\ndefn branch feature \u0026\u0026 defn checkout feature\n# make changes\ndefn commit \"add auth middleware\"\ndefn checkout main \u0026\u0026 defn merge feature\n```\n\nIn server mode, multiple agents branch and merge concurrently on the same Dolt server.\n\n## Scale\n\n| Project | Lines | Defs | Refs | Init time |\n|---------|-------|------|------|-----------|\n| chi | 10K | 370 | 704 | 11s |\n| gin | 24K | 1,580 | 3,829 | 48s |\n| hugo | 218K | 10,221 | 22,209 | 7min |\n\nInit is a one-time cost. Incremental resolve after edits is much faster.\n\n## Limitations\n\n- **Go only.** The type-checked reference graph requires `go/types`.\n- **`rename` uses AST-based identifier replacement** — preserves comments and string literals. Local variables that shadow the definition name are detected and preserved (with a warning).\n\n## License\n\nApache 2.0. Built on [Dolt](https://github.com/dolthub/dolt) (Apache 2.0) and [adit-code](https://github.com/justinstimatze/adit-code) research. See [INFLUENCES.md](INFLUENCES.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinstimatze%2Fdefn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinstimatze%2Fdefn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinstimatze%2Fdefn/lists"}