This document provides guidelines for Claude (AI assistant) when working on the Deepnote monorepo.
This is a TypeScript monorepo for Deepnote's open-source packages, managed with pnpm workspaces. The repository contains:
- packages/blocks - Core package for working with Deepnote blocks and notebook files
- packages/convert - Bidirectional converter between Jupyter Notebook files (
.ipynb) and Deepnote project files (.deepnote) - packages/database-integrations - Database integration definitions, schemas, and authentication methods
- packages/reactivity - Reactivity and dependency graph for Deepnote notebooks
Always run commands from the root directory unless specifically told otherwise.
# Run all tests
pnpm test
# Run tests with coverage
pnpm test:coverage# Type check all packages
pnpm typecheck# Check for linting and formatting issues
pnpm biome:check
# Auto-fix linting and formatting issues
pnpm biome:check:fix
# Check prettier formatting for markdown/yaml
pnpm prettier:check
# Auto-fix prettier formatting
pnpm prettier
# Run both biome and prettier checks
pnpm lintAndFormat
# Auto-fix both
pnpm lintAndFormat:fix# Build all packages
pnpm buildAlways run these checks before considering work complete:
- Tests -
pnpm test- All tests must pass - Type Check -
pnpm typecheck- No TypeScript errors - Linting -
pnpm biome:check- Code must pass Biome linter
- Create comprehensive tests for all new features
- Place test files next to the source files with
.test.tsor.test.tsxextension - Use Vitest as the testing framework
- Follow existing test patterns in the codebase (see
packages/blocks/src/blocks/*.test.ts) - Test edge cases, error handling, and special characters
- For functions that generate code, test the exact output format
- Use strict type checking
- Prefer type safety over convenience
- Use
constfor immutable values - Avoid
anytypes - use proper type definitions
- Follow Biome's rules (configured in
biome.json) - Use literal keys instead of bracket notation when possible
- Prefer single quotes for strings (except when avoiding escapes)
- Keep code clean and readable
Location: packages/blocks/
Purpose: Core package for working with Deepnote blocks, converting between Deepnote and Jupyter formats, and generating Python code from block configurations.
Key modules:
src/blocks/- Block type definitions and code generationcode-blocks.ts- Code block handlingsql-blocks.ts- SQL block handlingdata-frame.ts- DataFrame configuration for table displayinput-blocks.ts- Input widgets (text, checkbox, select, etc.)python-utils.ts- Python string escaping utilities
src/deserialize-file/- .deepnote file parsingsrc/python-code.ts- Main entry point for Python code generation
Common patterns:
- Use
escapePythonString()for safely embedding strings in Python code - Use
ts-dedentfor clean multiline template strings - Block metadata contains configuration like
deepnote_table_state,deepnote_variable_name, etc. - Always include DataFrame config when generating code for code/SQL blocks
- Create a
.test.tsfile next to the source file - Import test utilities from vitest:
import { describe, expect, it } from 'vitest' - Group related tests with
describe()blocks - Write clear test names that describe the expected behavior
- Use
dedentfromts-dedentfor multiline string comparisons - Run tests to verify:
pnpm test
- Run
pnpm biome:checkto see issues - Many issues can be auto-fixed with
pnpm biome:check:fix - For remaining issues, manually address them following the linter's suggestions
- Common fixes:
- Replace bracket notation with dot notation:
obj['prop']→obj.prop - Use consistent quotes: prefer single quotes
- Remove unused imports/variables
- Replace bracket notation with dot notation:
- Run
pnpm typecheckto see all type errors - Fix type errors by:
- Adding proper type annotations
- Using type guards for conditional access
- Ensuring function signatures match implementations
- Properly typing object properties
- Source code:
packages/*/src/ - Tests: Co-located with source as
*.test.ts - Test fixtures:
test-fixtures/(shared across all packages) - Types: Define inline or in separate
types.tsfiles - Build output:
packages/*/dist/(gitignored)
Always place test fixtures in the shared test-fixtures/ directory at the repository root, not in package-specific __fixtures__ directories. This allows fixtures to be reused across packages.
To reference fixtures from a test file:
import path from "node:path";
const testFixturesDir = path.join(__dirname, "../../../test-fixtures");
const fixturePath = path.join(testFixturesDir, "my-fixture.ipynb");The skills/deepnote/ directory contains reference documentation used by AI agents. When making changes to any of the following, you must also update the corresponding skill files:
.deepnotefile format (block types, metadata, schema) — updateskills/deepnote/references/blocks-*.mdandskills/deepnote/references/schema.ts- CLI commands (options, output formats, exit codes, new commands) — update
skills/deepnote/references/cli-*.md - MCP tools (tool names, parameters, behavior) — update
skills/deepnote/references/cli-*.md(MCP mirrors CLI commands)
- Never commit without running tests, typecheck, and linting
- Always preserve existing functionality - check that changes don't break other tests
- Follow existing code patterns - look at similar code in the repo for guidance
- Use pnpm, not npm or yarn - this is enforced by packageManager field
- Read error messages carefully - they often contain the solution
- When updating code generation, update corresponding tests to match new output format
- Package Manager: pnpm 10.18.1+
- Node Version: 22.14.0+
- Build Tool: tsdown
- Test Framework: Vitest
- Linter: Biome
- Formatter: Biome + Prettier (for md/yaml)
- Type Checker: TypeScript 5.9.3
- Check existing tests for examples
- Read error messages - they're usually helpful
- Look at similar code in the repository
- Review CONTRIBUTING.md for contribution guidelines