CodeSQL Index source trees into queryable tables for symbols, references, imports, docs, and parse diagnostics. integrations guide integrations/codesql integrations/codesql.md

CodeSQL

Index source trees into queryable tables for symbols, references, imports, docs, and parse diagnostics.

What CodeSQL exposes

CodeSQL is a managed kind: code source. GraphJin indexes the source tree into a read-only SQLite runtime database and exposes the public projection as gj_code.

YAML
sources:
  - name: code
    kind: code
    path: ../app
    capabilities:
      code.search: true
      code.read: true
      code.write: false
      code.watch: false
      code.infer_db_refs: true
gj_code.kindWhat it represents
fileSource files, paths, hashes, languages, and text metadata
symbolFunctions, types, classes, methods, and their byte ranges
ref / db_refCode references, including database/table/column references when inferred
importImport edges between files/modules
docIndexed documentation text
parse_errorTree-sitter diagnostics for files that could not be parsed cleanly
Verified by TestCodeSQLMultiDBInitializesManagedSQLiteRuntime serv/codesql_test.go:16

Query code like data

GraphQL
query {
  gj_code(
    where: { kind: { eq: "symbol" }, name: { iregex: "Reload" } }
    limit: 20
    order_by: { path: asc }
  ) {
    name
    symbol_kind
    path
    language
    start_byte
    end_byte
  }
}

Verified by TestCodeSQLServiceLiveIndexAndWatch tests/codesql_live_test.go:18
Verified by TestMetadataGraphLiveLinksCodeSQLRefs tests/codesql_live_test.go:67

Agentic workflow

Agents can discover source facts through gj_catalog, inspect security posture, preview edits, and only apply changes through policy-controlled source operations.

Use CodeSQL when a model needs evidence from source code without raw shell access.

Preview and apply edits

Write-capable CodeSQL does not expose raw derived-table mutation roots. Source edits go through change-set rows with hashes, byte ranges, expected old text, preview diffs, optional locks, and an explicit apply action.

GraphQL
mutation PreviewCodeChange($input: gj_code_insert_input!) {
  gj_code(insert: $input) {
    id
    kind
    status
    diff
    errors_json
  }
}

Verified by TestCodeSQLGraphQLSourceMutationsPreviewApplyAndLocks serv/codesql_test.go:267
Verified by TestCodeSQLRawTableMutationRootsUnavailable serv/codesql_test.go:657

In development, live watch is enabled by default. In production, enable it only with code.watch: true; read-only CodeSQL disables live watching and source mutations.

Verified by TestCodeSQLProductionDisablesLiveWatcherByDefault serv/codesql_test.go:103
Verified by TestCodeSQLProductionEnablesLiveWatcherWithCapability serv/codesql_test.go:136

Docs