agentleFS
genlayerlabsgenlayerlabs/genlayer-studio/CLAUDE.md

genlayer-studio

CLAUDE.md180 starsChanged 8 months agoMITView on GitHub

GenLayer Studio is a blockchain development sandbox for "Intelligent Contracts" - smart contracts that can interact with LLMs. It uses a microservices architecture with Docker Compose orchestration.

  • Reads credentials
  • Installs packages

The file

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

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Use @gl.public.view for read-only methods

    line 74
  2. Very specific:

    Use @gl.public.write for state-changing methods

    line 75
  3. Very specific:

    Use @gl.public.llm_query for non-deterministic LLM queries

    line 76
  4. Distinctive:

    All stores persist to localStorage via pinia-plugin-persistedstate

    line 89

≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.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
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Commands

Frontend Development

cd frontend/
npm run dev          # Start development server (port 5173)
npm run build        # Production build
npm run test         # Run unit tests with Vitest
npm run test:e2e     # End-to-end tests with Mocha/Selenium
npm run lint         # ESLint with auto-fix
npm run format       # Prettier formatting

Backend & Full Stack

genlayer up          # Start all services via Docker Compose
genlayer init        # Initialize project database
genlayer down        # Stop all services
docker compose up    # Alternative: start services directly
docker compose down -v  # Stop and clear data

Testing

# DB/SQLAlchemy tests (dockerized, self-contained - primary backend tests)
docker compose -f tests/db-sqlalchemy/docker-compose.yml --project-directory . run --build --rm tests

# Backend unit tests (requires local venv with deps installed)
# python -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt
.venv/bin/pytest tests/unit/ -v --tb=short --ignore=tests/unit/test_rpc_endpoint_manager.py

# Integration tests (requires venv + running containers via docker compose up)
.venv/bin/gltest --contracts-dir . tests/integration/ -svv

# Frontend tests
cd frontend && npm run test      # Unit tests (Vitest)
cd frontend && npm run test:e2e  # E2E tests (Mocha/Selenium)

Database Operations

# Run from backend container
docker exec -it genlayer-studio-backend-1 bash
alembic upgrade head  # Apply migrations
alembic revision --autogenerate -m "description"  # Create migration

Architecture

GenLayer Studio is a blockchain development sandbox for "Intelligent Contracts" - smart contracts that can interact with LLMs. It uses a microservices architecture with Docker Compose orchestration.

Service Architecture

  • Frontend (Vue 3 + TypeScript): SPA on port 8080, uses Pinia stores, TanStack Query, Socket.io for real-time updates
  • Backend (Python Flask): JSON-RPC API on port 4000, handles consensus, contract execution
  • Database: PostgreSQL with SQLAlchemy ORM, Alembic migrations
  • WebDriver: Selenium service for contract execution sandboxing
  • GenVM: Custom Python VM for executing intelligent contracts with LLM capabilities

Key Directories

  • frontend/src/stores/: Pinia state management (simulator, contracts, accounts)
  • frontend/src/components/Simulator/: Contract execution UI components
  • backend/consensus/: Custom PoS consensus with LLM validators
  • backend/node/genvm/: GenLayer Virtual Machine implementation
  • backend/protocol_rpc/: JSON-RPC endpoint handlers
  • backend/validators/: LLM provider integrations (OpenAI, Anthropic, etc.)
  • examples/contracts/: Sample intelligent contracts

Contract Development

Intelligent contracts are Python classes inheriting from gl.Contract:

  • Use @gl.public.view for read-only methods
  • Use @gl.public.write for state-changing methods
  • Use @gl.public.llm_query for non-deterministic LLM queries
  • Contracts can make web requests and interact with multiple LLM providers

Consensus System

  • Uses multiple LLM providers as validators in a custom consensus mechanism
  • Supports deterministic execution (all validators agree) and non-deterministic (majority vote)
  • Validator rotation using VRF (Verifiable Random Function)
  • Configurable validator sets in backend/node/base/leader_election.py

Frontend State Management

  • SimulatorStore: Main store for contract execution and state
  • ContractsStore: Manages deployed contracts and their code
  • AccountsStore: Handles user accounts and balances
  • All stores persist to localStorage via pinia-plugin-persistedstate

API Communication

  • Primary: JSON-RPC over HTTP (port 4000)
  • Real-time: Socket.io for consensus updates
  • Frontend uses TanStack Query for caching and state synchronization
  • API client: frontend/src/services/api.ts

Environment Configuration

Key environment variables (see .env.example):

  • POSTGRES_*: Database connection
  • PROVIDERS_*: LLM provider API keys
  • DEFAULT_VALIDATORS_COUNT: Consensus participants

Testing Approach

  • Backend: pytest with fixtures in tests/common/
  • Frontend: Vitest for unit tests, Mocha/Selenium for E2E
  • Integration tests use Docker Compose test profiles
  • Contract tests in tests/integration/test_contracts/

Code Style

  • Python: Black formatter, type hints required
  • TypeScript: ESLint + Prettier, strict mode enabled
  • Pre-commit hooks enforce formatting (see .pre-commit-config.yaml)
  • Vue: Composition API with <script setup> syntax

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.