What is Go Cursor SDK?
Go Cursor SDK is a full-featured Go library for reading and parsing all local data from Cursor IDE. It provides a unified, type-safe interface to access session records, Composer data, AI statistics, user configurations, and more.
Key Features
Unified Client Architecture
The SDK provides a CursorClient that serves as a unified entry point to all Cursor IDE data:
client, err := cursor.NewCursorClient(config)
if err != nil {
log.Fatal(err)
}
defer client.Close()
// Access different types of data through specialized readers
sessions := client.Sessions()
composers := client.Composers()
stats := client.Stats()Comprehensive Data Access
Access all types of Cursor IDE data:
- Session Records: AI conversation history
- Composer Data: Code modification sessions and statistics
- AI Statistics: Daily code generation metrics and acceptance rates
- User Configuration: Settings and personal context
- Workspace Data: Project-specific information
- Terminal History: Command and directory history
- MCP Services: Model Context Protocol server information
- Agent Layout: UI layout configuration
- And more...
Type-Safe API
All data structures are strongly typed, providing compile-time safety and excellent IDE support:
type Session struct {
ID string
CreatedAt time.Time
UpdatedAt time.Time
Title string
Messages []Message
Files []FileRef
Metadata Metadata
}Performance Optimized
Built-in caching and concurrent access support ensure optimal performance:
config := &cursor.ClientConfig{
EnableCache: true,
CacheTTL: 10 * time.Minute,
}Read-Only and Safe
The SDK operates in read-only mode, ensuring it never modifies your Cursor IDE data:
- All database connections are opened with read-only flags
- No write operations are exposed in the API
- Safe to use alongside running Cursor IDE
Use Cases
Analytics and Reporting
Generate insights about your AI-assisted development:
stats, _ := client.Stats().GetStatsRange(startDate, endDate)
// Analyze acceptance rates, productivity metrics, etc.Data Export and Backup
Export your Cursor data for backup or analysis:
client.Export().ExportAll("./backup", client)Integration with Other Tools
Build custom tools that integrate with Cursor IDE:
// Watch for new sessions and trigger actions
watcher := client.Watcher()
watcher.WatchSessions(func(event cursor.WatchEvent) {
// Handle new session
})Research and Analysis
Study AI-assisted development patterns:
aiReader, _ := cursor.NewAITrackingReader(config)
hashes, _ := aiReader.ListAICodeHashes()
// Analyze code generation patternsArchitecture
The SDK follows clean architecture principles:
┌─────────────────────────────────────┐
│ CursorClient │
│ (Unified Entry Point) │
└─────────────────────────────────────┘
│
├─── SessionReader
├─── ComposerReader
├─── StatsReader
├─── ConfigReader
├─── WorkspaceReader
├─── TerminalHistoryReader
├─── MCPServiceReader
├─── AgentLayoutReader
└─── ... (more readers)
│
├─── Parsers (internal)
└─── Storage Locators (internal)Design Principles
- Separation of Concerns: Public API is separated from internal implementation
- Resource Management: Proper cleanup with
Close()methods - Error Handling: Detailed error types for different failure scenarios
- Concurrent Safety: Thread-safe operations with proper locking
- Extensibility: Easy to add new readers for additional data types
Next Steps
- Getting Started - Install and use the SDK
- Installation - Detailed installation instructions
- API Reference - Complete API documentation