AI Coding Tools

Configure Cursor, Claude Code, Windsurf, and GitHub Copilot to suggest JustAnalytics patterns.

Overview#

JustAnalytics provides pre-built configuration templates for popular AI coding tools. These templates teach your AI assistant about JustAnalytics SDK patterns, so it can suggest correct instrumentation code as you work.

Supported tools:

  • Cursor (.cursorrules)
  • Claude Code (CLAUDE.md)
  • Windsurf (.windsurfrules)
  • GitHub Copilot (.github/copilot-instructions.md)

Quick Setup#

Run the configuration generator in your project root:

npx @justanalyticsapp/ai-config init

The CLI will:

  1. Auto-detect which AI tools you use (from .cursor/, .github/, etc.)
  2. Auto-detect your JustAnalytics SDK language (from package.json, requirements.txt, etc.)
  3. Generate customized config files with real SDK patterns

Options#

# Generate configs for specific tools
npx @justanalyticsapp/ai-config init --tools cursor,copilot

# Specify SDK language explicitly
npx @justanalyticsapp/ai-config init --sdk node --framework next

# Generate configs for all supported tools
npx @justanalyticsapp/ai-config init --all

# Overwrite existing config files
npx @justanalyticsapp/ai-config init --overwrite

# Scan a different directory
npx @justanalyticsapp/ai-config init --dir /path/to/project

Other Commands#

# List all supported AI tools
npx @justanalyticsapp/ai-config list

# Detect tools and SDKs without generating files
npx @justanalyticsapp/ai-config detect

What Gets Generated#

Cursor (.cursorrules)#

Teaches Cursor about:

  • JustAnalytics SDK initialization patterns
  • How to wrap operations in spans (startSpan)
  • Error tracking (captureException)
  • Structured logging (JA.logger)
  • Custom metrics (recordMetric)
  • Framework-specific patterns (Next.js, Express, Django, etc.)
  • Auto-instrumented features (HTTP, PostgreSQL, Redis)
  • Best practices and environment variables

Claude Code (CLAUDE.md)#

Provides Claude Code with:

  • Project observability context
  • SDK initialization patterns
  • Instrumentation recipes for tracing, errors, logs, and metrics
  • Debugging guidance (Trace Explorer, Log Explorer, Service Map)
  • Links to documentation

Windsurf (.windsurfrules)#

Configures Windsurf with:

  • SDK setup and auto-instrumentation details
  • Code pattern suggestions
  • Coding guidelines for observability
  • API references

GitHub Copilot (.github/copilot-instructions.md)#

Teaches Copilot:

  • When to suggest JustAnalytics patterns (try/catch, API endpoints, logging, etc.)
  • Correct SDK import and initialization
  • Common instrumentation patterns
  • Environment variable requirements

Supported SDKs#

The templates are customized based on your SDK language:

| SDK | Package | Detection | |-----|---------|-----------| | Node.js | @justanalyticsapp/node | package.json | | Python | justanalytics | requirements.txt, pyproject.toml | | Go | github.com/justanalyticsapp/go-sdk | go.mod | | Ruby | justanalytics | Gemfile | | PHP | justanalyticsapp/sdk | composer.json | | Java/Kotlin | com.github.specifiedcodes.justanalytics-java | build.gradle, pom.xml |

Supported Frameworks#

Framework-specific patterns are included when detected:

  • Next.js - instrumentation.ts, withTracing, withMiddlewareTracing, traceServerComponent
  • Express - expressMiddleware(), error handler patterns
  • Django - Middleware setup, settings.py configuration
  • Flask - flask.instrument() setup
  • FastAPI - fastapi.instrument() setup
  • Gin - HTTP handler instrumentation

Customizing Templates#

After generating, feel free to edit the config files to:

  • Add project-specific conventions
  • Include internal API references
  • Add custom span naming patterns
  • Document your alerting rules and SLOs

The generated files are a starting point. Commit them to your repository so all team members benefit from consistent AI suggestions.

Example: Next.js Project#

# In a Next.js project with @justanalyticsapp/node installed
$ npx @justanalyticsapp/ai-config init --all

JustAnalytics AI Config Generator
=================================

Scanning project: /Users/dev/my-next-app

Detected SDK(s): node
Detected framework: next
Package manager: npm

Generating configs for: Cursor, Claude Code, Windsurf, GitHub Copilot

  Created: .cursorrules
  Created: CLAUDE.md
  Created: .windsurfrules
  Created: .github/copilot-instructions.md

Done! 4 file(s) created, 0 skipped.

Now when you ask Cursor to "add error tracking to this endpoint", it will suggest:

import JA from '@justanalyticsapp/node';

export const GET = withTracing(async (req, { params }) => {
  try {
    const user = await db.users.findUnique({ where: { id: params.id } });
    return Response.json(user);
  } catch (error) {
    JA.captureException(error, {
      tags: { endpoint: '/api/users' },
    });
    return Response.json({ error: 'Internal server error' }, { status: 500 });
  }
});