This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Chalkpad is an interactive content creation tool built with ClojureScript and React/Reagent. It allows users to create and edit blocks of markdown and code in a notebook-style interface with syntax highlighting via CodeMirror.
- ClojureScript with Reagent (React wrapper) for UI
- Shadow-CLJS for build tooling and development server
- CodeMirror 6 for code editing with syntax highlighting
- Marked library for markdown rendering
src/chalkpad/core.cljs- Main application entry point and mounting logicsrc/chalkpad/state.cljs- Global state management with atom-based storesrc/chalkpad/ui/blocks.cljs- Block components (markdown/code blocks) and main editor UIsrc/chalkpad/ui/codemirror.cljs- CodeMirror integration and text editor component
The application uses a single global atom !doc in chalkpad.state that contains:
:blocks- Vector of block objects with:id,:type(:markdown or :code),:content,:lang(for code), and:editing?flag
Block operations include:
add-block!- Add new markdown or code blocksupdate-block!- Update block properties (content, type, editing state)remove-block!- Delete blocksmove-block!- Reorder blocks up/down
npm run dev- Start development server with hot reload (shadow-cljs watch)npm run release- Build production bundle (shadow-cljs release)npm run clean- Clean build artifactsnpm run repl- Start ClojureScript REPL
- Run
npm run devto start the development server - Navigate to
http://localhost:3000(configured in shadow-cljs.edn:dev-http) - The app auto-reloads on file changes via shadow-cljs hot reload
shadow-cljs.edn- Build configuration with browser target outputting topublic/jspackage.json- NPM dependencies and scripts- Entry point:
chalkpad.core/initfunction
- Markdown blocks: Editable text with live preview using marked library
- Code blocks: Syntax-highlighted editor supporting JavaScript and ClojureScript
- Block controls: Move up/down, convert type, delete functionality
- Custom Reagent wrapper for CodeMirror 6
- Language-specific extensions for JavaScript, ClojureScript, and Markdown
- Bidirectional data binding between editor and application state
- Use kebab-case for function and variable names
- Prefix atoms and mutable references with
!(e.g.,!doc,!text) - Use
defoncefor application state to preserve during hot reload - Separate UI components into focused, single-responsibility functions
- Keep UI components in
ui/subdirectory - Separate state management from UI components
- Use namespaced keywords for component types (
:markdown,:code)