agentleFS
Alba-IntelligenceAlba-Intelligence/cl-tron-mcp/AGENTS.md

cl-tron-mcp

AGENTS.md9 starsChanged 10 months agoApache-2.0View on GitHub

This document provides guidelines for AI agents working on the SBCL Debugging MCP project - a Model Context Protocol server that enables deep debugging, introspection, profiling, and hot code reloading for SBCL Common Lisp applications. What is Tron? An MCP server that connects to a running SBCL Lisp session and provides debugging, code evaluation, inspection, profiling, and hot-reload capabilities. Tron exposes documentation and guided workflows via MCP standard mechanisms: Recommended: Start with prompts/get for getting-started workflow to learn the connection…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

15 rules. About 0 are common, 9 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Recommended: Start with prompts/get for getting-started workflow to learn the connection pattern.

    line 22
  2. Distinctive:

    Start with SBCL Debugging Expert to identify the issue using stack traces and local variable inspection

    line 134
  3. Distinctive:

    Use Hot Reload Specialist to apply the fix without restarting

    line 135
  4. Distinctive:

    Use Performance Engineer to verify the improvement and ensure no regressions

    line 136
  5. Distinctive:

    Use SBCL Debugging Expert to inspect the current state and understand the code structure

    line 148
  6. Distinctive:

    Use Hot Reload Specialist to compile and load the modified code

    line 149
  7. Distinctive:

    Use Performance Engineer to profile the application and identify bottlenecks

    line 162
  8. Distinctive:

    Use Hot Reload Specialist to apply optimizations

    line 163
  9. Very specific:

    First time using Tron?: Start with the getting-started prompt

    line 208
  10. Very specific:

    Need help discovering features?: Use the discover-mcp prompt

    line 209
  11. Very specific:

    Debugging an error?: Use sbcl-debugging-expert

    line 210
  12. Very specific:

    Fixing code without restart?: Use hot-reload-specialist

    line 211
  13. Very specific:

    Improving performance?: Use performance-engineer

    line 212
  14. Distinctive:

    Whitelist: When the operation is whitelisted, the tool runs without prompting.

    line 491
  15. Distinctive:

    All operations are logged with:

    line 495

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

SBCL Debugging MCP Repository Guidelines

Image: Token Efficiency

This document provides guidelines for AI agents working on the SBCL Debugging MCP project - a Model Context Protocol server that enables deep debugging, introspection, profiling, and hot code reloading for SBCL Common Lisp applications.

Quick Start

What is Tron? An MCP server that connects to a running SBCL Lisp session and provides debugging, code evaluation, inspection, profiling, and hot-reload capabilities.

Discovering How to Use Tron

Tron exposes documentation and guided workflows via MCP standard mechanisms:

MethodPurpose
resources/listList available documentation files
resources/readRead a documentation file by URI
prompts/listList available guided workflows
prompts/getGet step-by-step instructions for a workflow

Recommended: Start with prompts/get for getting-started workflow to learn the connection pattern.

Modular Documentation

This guide has been modularized for better token efficiency. Each section is now a separate document:

Core Documentation

  • Getting Started - First-time setup, connection patterns, and basic usage
  • Workflows - Common workflows: evaluate, debug, inspect, profile, hot-reload
  • Tool Reference - Complete tool catalog organized by category
  • Conventions - Coding style, naming conventions, and best practices
  • Transport & Logging - Transport modes, stdio requirements, and logging
  • Troubleshooting - Common issues and solutions
  • Token Optimization - Principles for reducing token usage

Choosing the Right Agent

This guide helps you select the appropriate specialized agent for your task. Tron provides three specialized agent personas, each optimized for specific workflows.

Decision Matrix

Your GoalUse This AgentWhy
Debug an error in SBCLSBCL Debugging ExpertSpecialized in error analysis, stack frame inspection, and restart navigation
Fix a bug without restartingHot Reload SpecialistExpert in live code modification and hot-swapping definitions
Improve performancePerformance EngineerSpecialized in profiling, bottleneck identification, and optimization
Inspect objects or data structuresSBCL Debugging ExpertProvides deep introspection capabilities for runtime state
Trace function executionSBCL Debugging ExpertCan set up function tracing and analyze call patterns
Monitor production systemPerformance EngineerProvides health checks, runtime stats, and production monitoring
Learn how to use TronAny agent (start with discover-mcp prompt)All agents can guide you through MCP discovery

Agent Profiles

SBCL Debugging Expert

Primary Use Case: Deep debugging and error analysis in SBCL applications.

Trigger Conditions:

  • You encounter an error or exception
  • You need to inspect stack frames or local variables
  • You want to understand the current debugger state
  • You need to navigate available restarts
  • You want to trace function execution

Key Capabilities:

  • Stack frame inspection and navigation
  • Local variable examination
  • Restart analysis and invocation
  • Breakpoint management
  • Function tracing

Prompt: sbcl-debugging-expert

Hot Reload Specialist

Primary Use Case: Live code modification without restarting the SBCL session.

Trigger Conditions:

  • You need to fix a bug in running code
  • You want to test changes immediately
  • You need to reload a system or package
  • You're developing with a rapid iteration cycle
  • You want to preserve application state while updating code

Key Capabilities:

  • Compile and load code strings
  • Reload ASDF systems
  • Hot-swap function definitions
  • Verify code changes
  • Manage compilation errors

Prompt: hot-reload-specialist

Performance Engineer

Primary Use Case: Performance analysis and optimization of SBCL applications.

Trigger Conditions:

  • Your application is slow or unresponsive
  • You need to identify performance bottlenecks
  • You want to profile function execution
  • You need to monitor resource usage
  • You're optimizing critical code paths

Key Capabilities:

  • Statistical profiling
  • Function-level performance analysis
  • Runtime statistics
  • Health monitoring
  • Thread analysis

Prompt: performance-engineer

Agent Collaboration Patterns

Some workflows benefit from using multiple agents in sequence:

1. Debug → Fix → Profile

SBCL Debugging Expert → Hot Reload Specialist → Performance Engineer

Workflow:

  1. Start with SBCL Debugging Expert to identify the issue using stack traces and local variable inspection
  2. Use Hot Reload Specialist to apply the fix without restarting
  3. Use Performance Engineer to verify the improvement and ensure no regressions

Use Case: Fixing a performance bug in a running application

2. Inspect → Modify → Verify

SBCL Debugging Expert → Hot Reload Specialist → SBCL Debugging Expert

Workflow:

  1. Use SBCL Debugging Expert to inspect the current state and understand the code structure
  2. Use Hot Reload Specialist to compile and load the modified code
  3. Return to SBCL Debugging Expert to verify the changes work correctly

Use Case: Iterative development with live testing

3. Profile → Optimize → Validate

Performance Engineer → Hot Reload Specialist → Performance Engineer

Workflow:

  1. Use Performance Engineer to profile the application and identify bottlenecks
  2. Use Hot Reload Specialist to apply optimizations
  3. Return to Performance Engineer to validate performance improvements

Use Case: Performance optimization cycle

Example Workflows

Debugging a Runtime Error

;; 1. Connect to SBCL and inspect the error
(cl-tron-mcp/tools:debugger_frames)
(cl-tron-mcp/tools:debugger_restarts)

;; 2. Examine local variables in the failing frame
(cl-tron-mcp/tools:repl_frame_locals :frame-id 0)

;; 3. Fix the issue with hot reload
(cl-tron-mcp/tools:code_compile_string :code "(defun my-fixed-function ...)")

;; 4. Verify the fix works
(cl-tron-mcp/tools:repl_eval :code "(my-fixed-function)")

Performance Optimization

;; 1. Start profiling
(cl-tron-mcp/tools:profile_start)

;; 2. Run the code to profile
;; ... (execute your application code) ...

;; 3. Stop profiling and analyze results
(cl-tron-mcp/tools:profile_stop)

;; 4. Apply optimizations with hot reload
(cl-tron-mcp/tools:code_compile_string :code "(defun optimized-function ...)")

;; 5. Verify improvement
(cl-tron-mcp/tools:runtime_stats)

Quick Reference

  • First time using Tron? Start with the getting-started prompt
  • Need help discovering features? Use the discover-mcp prompt
  • Debugging an error? Use sbcl-debugging-expert
  • Fixing code without restart? Use hot-reload-specialist
  • Improving performance? Use performance-engineer

For detailed workflow examples, see docs/agents/workflows.md.

Token Optimization Refactoring

Overview

In February 2026, a comprehensive token optimization refactoring was completed to reduce token usage by ~50% while maintaining full functionality.

Key Improvements

  1. Tool Description Extraction - Moved verbose tool descriptions to external documentation (docs/tools/)
  2. Dynamic Help Generation - Refactored help functions to use tool registry dynamically
  3. Error Code Consolidation - Implemented error codes with lazy-loaded hints
  4. Token Measurement Infrastructure - Added token tracking and benchmarking capabilities

Benchmark Results

  • Total Token Savings: 49.5% (2501 → 1263 tokens)
  • Average Reduction: 60.7% across 5 scenarios

See reports/token-benchmark-report.md for detailed results.

Documentation

  • Token Optimization Guide
  • Benchmark Report
  • Tool Documentation

Quick Reference

Essential Pattern: One Long-Running Session

┌─────────────────┐         ┌─────────────────┐
│  SBCL + Swank   │◄───────►│   Tron (MCP)    │
│  (Port 4006)    │         │   (stdio)       │
│                 │         │                 │
│  Your code      │         │   AI Agent      │
│  Debugger state │         │   evaluates     │
│  Threads        │         │   inspects      │
└─────────────────┘         └─────────────────┘

Never restart the SBCL session. Tron connects as a client; all state lives in SBCL.

Core Development Loop:

EXPLORE → EXPERIMENT → PERSIST → VERIFY → HOT-RELOAD
          ↑                              ↓
          └────────── REFINE ───────────┘

MCP Protocol Methods:

MethodPurpose
resources/listList documentation files (AGENTS.md, docs/*)
resources/readRead a documentation file by URI
prompts/listList guided workflows
prompts/getGet step-by-step workflow instructions
tools/listList available tools
tools/callInvoke a tool
PromptPurpose
discover-mcpHow to fully use this MCP without user explanation (ordered discovery steps)
getting-startedHow to connect to Swank and verify setup
debugging-workflowStep-by-step error debugging
hot-reload-workflowLive code modification without restart
profiling-workflowPerformance analysis workflow
token-optimizationPrinciples for reducing token usage
sbcl-debugging-expertSpecialized SBCL debugging workflows
hot-reload-specialistHot code reloading specialist workflows
performance-engineerPerformance profiling and optimization workflows

Tool Categories (91 tools total)

CategoryPurposeKey Tools
InspectorObject introspectioninspect_object, inspect_class, inspect_function
DebuggerDebugging operationsdebugger_frames, debugger_restarts, breakpoint_set, breakpoint_toggle
REPLLegacy direct code evaluationrepl_eval
Hot ReloadLive code modificationcode_compile_string, reload_system
ProfilerPerformance analysisprofile_start, profile_stop
TracerFunction tracingtrace_function, trace_list
ThreadsThread managementthread_list, thread_inspect, thread_backtrace
MonitorProduction monitoringhealth_check, runtime_stats
LoggingPackage logginglog_configure, log_info
XRefCross-referencewho_calls, who_references, list_callees
SecurityApproval whitelistwhitelist_add, whitelist_status
SwankRaw Swank operations (21)swank_connect, swank_eval, swank_backtrace, swank_step
Managed ProcessesLaunch and supervise SBCL+Swank children (4)swank_launch, swank_process_list, swank_kill
UnifiedPreferred high-level REPL workflow (24)repl_connect, repl_eval, repl_step, repl_continue

Project Structure

cl-tron-mcp/
├── src/
│   ├── core/                    # Core infrastructure (config, utils, version, server)
│   ├── transport/              # Transport layer (stdio, http via Hunchentoot, websocket)
│   ├── protocol/                # MCP protocol handler (JSON-RPC 2.0)
│   ├── tools/                   # Tool registry, definitions, and registration of MCP tools
│   │   ├── macros.lisp          # Validation macros (define-validated-tool, define-simple-tool)
│   │   ├── inspector-tools.lisp # Inspector tools (5)
│   │   ├── debugger-tools.lisp  # Debugger tools (7)
│   │   ├── repl-tools.lisp      # REPL tools (1)
│   │   ├── hot-reload-tools.lisp # Hot reload tools (2)
│   │   ├── profiler-tools.lisp  # Profiler tools (3)
│   │   ├── tracer-tools.lisp    # Tracer tools (3)
│   │   ├── thread-tools.lisp    # Thread tools (3)
│   │   ├── monitor-tools.lisp   # Monitor tools (4)
│   │   ├── logging-tools.lisp   # Logging tools (5)
│   │   ├── xref-tools.lisp      # XRef tools (5)
│   │   ├── security-tools.lisp  # Security tools (5)
│   │   ├── swank-tools.lisp     # Swank tools (21)
│   │   ├── process-tools.lisp   # Managed Swank process tools (4)
│   │   ├── unified-tools.lisp   # Unified REPL tools (24)
│   │   ├── registry.lisp        # Tool registry and load-all-tools
│   │   └── register-tools.lisp  # Main loader (calls load-all-tools)
│   ├── security/                # Approval workflow, audit logging
│   ├── sbcl/                    # SBCL-specific integration (eval, compile, threads)
│   ├── swank/                   # Swank (Slime) integration
│   ├── unified/                 # Unified REPL interface (Swank)
│   ├── debugger/                # Debugging tools (frames, restarts, breakpoints)
│   ├── inspector/               # Object introspection tools
│   ├── hot-reload/              # Live code modification
│   ├── profiler/                 # Performance profiling
│   ├── tracer/                  # Function tracing
│   ├── monitor/                 # Production monitoring
│   ├── logging/                 # log4cl integration
│   └── xref/                    # Cross-reference tools
│
├── tests/                       # Rove test suites
├── scripts/                     # run-http.sh, run-http-server.lisp, tutorial-run.lisp, debug-mcp-stdio.sh
├── examples/                    # MCP config examples + mcp-kilocode.json, test_client.py, cl_tron_client.py
├── reports/                     # Result and diagnostic reports (not tmp/)
├── prompts/                     # Workflow-specific prompts
│   ├── individual/              # Individual prompt definitions (9 files)
│   │   ├── discover-mcp.lisp    # How to fully use this MCP
│   │   ├── getting-started.lisp # Connection setup
│   │   ├── debugging-workflow.lisp
│   │   ├── hot-reload-workflow.lisp
│   │   ├── profiling-workflow.lisp
│   │   ├── token-optimization.lisp
│   │   ├── sbcl-debugging-expert.lisp
│   │   ├── hot-reload-specialist.lisp
│   │   └── performance-engineer.lisp
│   └── handler.lisp              # Prompt infrastructure (159 lines)
├── agents/                      # Specialized agent personas
├── docs/
│   ├── agents/                  # Modular agent documentation (this guide split into 6 files)
│   │   ├── index.md             # This overview
│   │   ├── getting-started.md   # First-time setup
│   │   ├── workflows.md         # Common workflows
│   │   ├── tool-reference.md    # Tool catalog
│   │   ├── conventions.md       # Coding standards
│   │   ├── transport-logging.md # Transport & logging
│   │   └── troubleshooting.md   # Common issues
│   ├── tools/                   # Tool documentation
│   └── plans/                   # Planning docs (e.g. swank-integration)
├── .cursor/                     # Cursor MCP configs
├── .vscode/                     # VS Code MCP configs
├── .kilocode/                   # Kilocode MCP configs
├── cl-tron-mcp.asd             # ASDF system definition
└── README.md                    # Project overview

Build, Test, and Development Commands

Building the System

;; Load build via Quicklisp (recommended)
(ql:quickload :cl-tron-mcp)

;; Load via ASDF
(asdf:load-system :cl-tron-mcp)

;; Compile from source
(asdf:compile-system :cl-tron-mcp)

;; Force recompile
(asdf:compile-system :cl-tron-mcp :force t)

Running Tests

;; Run all tests via ASDF
(asdf:test-system :cl-tron-mcp)

;; Run via Rove
(ql:quickload :rove)
(ql:quickload :cl-tron-mcp)
(rove:run :cl-tron-mcp/tests)

;; Run specific test suite
(rove:run 'cl-tron-mcp/tests/core-test)
(rove:run 'cl-tron-mcp/tests/protocol-test)
(rove:run 'cl-tron-mcp/tests/security-test)

;; Run single test
(rove:run-test 'cl-tron-mcp/tests/core-test::version-test)

Development Server

;; Start MCP server (default: combined = stdio + HTTP on 4006)
(cl-tron-mcp/core:start-server)

;; Start MCP server (stdio only - e.g. when MCP client starts the server)
(cl-tron-mcp/core:start-server :transport :stdio-only)

;; Start MCP server (HTTP only via Hunchentoot; default port 4006)
(cl-tron-mcp/core:start-server :transport :http-only :port 4006)

;; Start MCP server (WebSocket transport)
(cl-tron-mcp/core:start-server :transport :websocket :port 23456)

;; Stop the server
(cl-tron-mcp/core:stop-server)

;; Check server state
(cl-tron-mcp/core:get-server-state)

Testing with MCP Client

# Test with stdio (--stdio-only for pure stdio, or default combined).
echo '{"jsonrpc": "2.0", "method": "initialize", "params": {}, "id": 1}' | \
  sbcl --non-interactive --noinform \
    --eval '(ql:quickload :cl-tron-mcp :silent t)' \
    --eval '(cl-tron-mcp/core:start-server :transport :stdio-only)'
# Or: echo '{"jsonrpc":"2.0","method":"initialize","params":{},"id":1}' | ./start-mcp.sh --stdio-only

# Quick verification
sbcl --non-interactive \
  --eval '(ql:quickload :cl-tron-mcp)' \
  --eval '(format t "Tools: ~d~%" (hash-table-count cl-tron-mcp/tools:*tool-registry*))'

Security & Configuration Notes

Security Model: User Approval Required

The MCP requires user approval for operations that can modify running code:

Operations Requiring Approval:

  • :eval - Code execution
  • :compile-file - Compilation
  • :modify-running-code - Hot swapping
  • :terminate-thread - Thread termination
  • :set-breakpoint - Breakpoint insertion
  • :trace-function - Function tracing
  • :modify-restarts - Restart manipulation

Tools Requiring Approval:

  • repl_eval
  • code_compile_string
  • reload_system
  • profile_start
  • profile_stop
  • trace_function
  • swank_eval, swank_compile, swank_abort, swank_interrupt
  • repl_eval, repl_compile

Approval Workflow (server-enforced)

  • Timeout: 300 seconds (user can be busy elsewhere).
  • Two classes: Tools with approvalLevel: "user" require human approval; "none" = auto-run (MCP/agent sufficient).
  • Flow: When a protected tool is invoked, the server returns approval_required with request_id and message. The client shows UI; the user approves or denies. The client calls approval/respond with request_id and approved (true/false). Then the client re-invokes the same tool with approval_request_id and approved: true to run it. Denial returns a message (e.g. "User denied approval. You can retry by invoking the tool again."). Retry = call the same tool again (new approval request).
  • Whitelist: When the operation is whitelisted, the tool runs without prompting.

Audit Logging

All operations are logged with:

  • Timestamp
  • Operation type
  • User approval status
  • Operation details (sanitized)
  • Duration
  • Result

MCP Client Integration

OpenCode Integration

Configure in ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "cl-tron-mcp": {
      "type": "local",
      "command": ["~/quicklisp/local-projects/cl-tron-mcp/start-mcp.sh"],
      "enabled": true
    }
  }
}

Cursor Integration

  1. Install the MCP extension for Cursor
  2. Copy .cursor/mcp.json to ~/.cursor/mcp.json

VS Code Integration

  1. Install the MCP extension for VS Code
  2. Copy .vscode/mcp.json to ~/.vscode/mcp.json

Kilocode Integration

  1. Copy .kilocode/mcp.json to appropriate config location (or use examples/kilocode-mcp.json.example with your path).
  2. If Kilocode does not connect: See docs/starting-the-mcp.md § Debugging Kilocode MCP: prove Tron alone (stdio), run the exact Kilocode command, use one transport at a time, check Kilocode/VS Code output, and optional ./scripts/debug-mcp-stdio.sh.

Manual Test (Verify Server Works)

echo '{"jsonrpc": "2.0", "method": "initialize", "params": {}, "id": 1}' | \
  sbcl --non-interactive --noinform \
    --eval '(ql:quickload :cl-tron-mcp :silent t)' \
    --eval '(cl-tron-mcp/core:start-server :transport :stdio-only)'

Or: echo '{"jsonrpc":"2.0","method":"initialize","params":{},"id":1}' | ./start-mcp.sh --stdio-only

Expected response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2024-11-05",
    "capabilities": [],
    "serverInfo": { "name": "cl-tron-mcp", "version": "0.1.0" }
  }
}

Cross-References

@docs/architecture.md @docs/mcp-resources-prompts.md @prompts/debugging-workflows.md @prompts/hot-reload-development.md @prompts/profiling-analysis.md @prompts/production-monitoring.md @agents/sbcl-debugging-expert.md @agents/performance-engineer.md @agents/hot-reload-specialist.md

Summary

  • Build: (ql:quickload :cl-tron-mcp)
  • Test: (asdf:test-system :cl-tron-mcp)
  • Dev Server: (cl-tron-mcp/core:start-server) (combined) or :transport :stdio-only / :http-only
  • Style: Google CL guide + project conventions
  • Tests: Rove in tests/, mirror source structure
  • Security: User approval required for modifying operations
  • Docs: See docs/agents/ for detailed guides (modularized for token efficiency)
  • Tools: 91 tools implemented across 14 categories
  • Transport: Combined (default: stdio + HTTP), stdio-only, http-only; WebSocket (placeholder)
  • MCP Clients: Verified working with OpenCode, Cursor, VS Code
  • Token Optimization: 49.5% token savings achieved through refactoring (Feb 2026)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.