-
-
Notifications
You must be signed in to change notification settings - Fork 140
Code Registry
The Code Registry is a SQLite-backed entity tracking system that registers every function, class, type, and interface across your codebase. It powers impact analysis, test mapping, risk assessment, and the BS Detector.
# Scan your repo openswarm check --scan # Inspect a file openswarm check src/myFile.ts # Find high-risk entities openswarm check --high-risk # Scan for bad code patterns openswarm check --bs
Supports 8 languages:
| Language | Extensions |
|---|---|
| TypeScript |
.ts, .tsx
|
| JavaScript |
.js, .jsx
|
| Python | .py |
| Go | .go |
| Rust | .rs |
| Java | .java |
| C |
.c, .h
|
| C++ |
.cpp, .hpp, .cc
|
| C# | .cs |
For each entity:
- Kind: function, class, interface, type, enum, method, etc.
-
Name: Qualified name (e.g.,
MyClass.myMethod) - Signature: Parameter types and return type
- Line range: Start and end line numbers
- Complexity: Cyclomatic complexity score
-
Status:
active,deprecated,experimental - Test mapping: Whether a corresponding test exists
- Risk level: Computed from complexity + test coverage
openswarm check src/foo.ts
Output: entities in the file, their kinds, test status, and risk flags.
openswarm check --stats
Shows: total entities, tested/untested counts, deprecated count, risk distribution.
openswarm check --search "authenticate"Full-text search using SQLite FTS5 index.
openswarm check --high-risk # Untested + high complexity openswarm check --untested # No corresponding test openswarm check --deprecated # Marked as deprecated openswarm check --tag "needs-refactor"
openswarm check --tree openswarm check --tree src/adapters
Shows directory tree with per-file entity counts, test percentage, and risk flags.
openswarm check --ci
Outputs JSON. Exit code 1 if critical BS issues are found. Suitable for CI/CD pipelines.
Mark entities with metadata for tracking:
# Deprecate openswarm annotate "OldClass" --deprecate "Use NewClass instead" # Tag openswarm annotate "myFunc" --tag "needs-refactor" openswarm annotate "myFunc" --untag "needs-refactor" # Status openswarm annotate "myFunc" --status experimental # Notes openswarm annotate "myFunc" --note "Handles empty input edge case" # Risk override openswarm annotate "myFunc" --risk high # Warnings openswarm annotate "myFunc" --warn "security: SQL injection risk"
Built-in static analysis that detects bad code patterns:
| Pattern | Example |
|---|---|
| Empty catch blocks | catch (e) {} |
| Hardcoded secrets | const API_KEY = "sk-..." |
as any casts |
foo as any |
| Console.log in production | console.log(...) |
| TODO/FIXME/HACK | // TODO: fix this later |
| Magic numbers | if (count > 42) |
| Long functions | Functions over threshold LOC |
| Deep nesting | 4+ levels of nesting |
openswarm check --bs # Full scan openswarm check --bs src/ # Scan specific directory openswarm check --ci # BS + registry in CI format
OpenSwarm injects Code Registry data into Claude Code sessions via hooks:
SessionStart hook: At session start, openswarm check --stats and --high-risk results are injected into context. This gives Claude Code an entity map so it can skip redundant Read/Grep calls.
Entity Map Injection: Worker agents receive entity lists (kind, name, signature, test status) in their prompts, eliminating the need to explore files before editing.
Registry data is stored in SQLite with WAL mode and FTS5:
~/.openswarm/registry.db
Per-project scoping is supported via the --project flag.
Getting Started
Reference
Deep Dive
Help