|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Quarto is an open-source scientific and technical publishing system built on Pandoc. The CLI is written in TypeScript/Deno with Lua filters for document processing. |
| 8 | + |
| 9 | +### Versions |
| 10 | + |
| 11 | +Latest stable is the version at: <https://quarto.org/docs/download/_download.json>. Latest prerelease is at: <https://quarto.org/docs/download/_prerelease.json> |
| 12 | + |
| 13 | +## Setup & Configuration |
| 14 | + |
| 15 | +### Initial Setup |
| 16 | + |
| 17 | +```bash |
| 18 | +# Clone and configure (downloads Deno, dependencies, and sets up symlink) |
| 19 | +./configure.sh # Linux/macOS |
| 20 | +./configure.cmd # Windows |
| 21 | + |
| 22 | +# The configure script: |
| 23 | +# - Downloads and installs Deno to package/dist/bin/tools/ |
| 24 | +# - Downloads Deno standard library |
| 25 | +# - Runs quarto-bld configure |
| 26 | +# - Vendors TypeScript dependencies |
| 27 | +# - Creates symlink to quarto in your PATH |
| 28 | +``` |
| 29 | + |
| 30 | +After configuration, the development version can be run via: |
| 31 | + |
| 32 | +- `quarto` command (if symlink configured) |
| 33 | +- `package/dist/bin/quarto` (Linux/macOS) or `package/dist/bin/quarto.cmd` (Windows) |
| 34 | + |
| 35 | +### Configuration Files |
| 36 | + |
| 37 | +- `configuration` - Version numbers for all binary and JavaScript dependencies (Deno, Pandoc, Dart Sass, etc.) |
| 38 | +- `deno.jsonc` - Auto-generated Deno configuration (see dev-docs/update-deno_jsonc.md) |
| 39 | +- `src/import_map.json` - Deno import mappings |
| 40 | +- `src/dev_import_map.json` - Development import mappings |
| 41 | + |
| 42 | +## Building & Testing |
| 43 | + |
| 44 | +### Build Commands |
| 45 | + |
| 46 | +```bash |
| 47 | +# Run the build script (TypeScript-based) |
| 48 | +package/src/quarto-bld configure # Configure/bootstrap |
| 49 | +package/src/quarto-bld prepare # Prepare distribution |
| 50 | +``` |
| 51 | + |
| 52 | +### Building Schemas and Artifacts |
| 53 | + |
| 54 | +Use the `dev-call` command with `build-artifacts` argument: |
| 55 | + |
| 56 | +```bash |
| 57 | +# Linux/macOS |
| 58 | +package/dist/bin/quarto dev-call build-artifacts |
| 59 | + |
| 60 | +# Windows |
| 61 | +package/dist/bin/quarto.cmd dev-call build-artifacts |
| 62 | +``` |
| 63 | + |
| 64 | +This command regenerates: |
| 65 | + |
| 66 | +- JSON schemas in `src/resources/schema/json-schemas.json` |
| 67 | +- Zod schemas in `src/resources/types/zod/schema-types.ts` |
| 68 | +- TypeScript type definitions in `src/resources/types/schema-types.ts` |
| 69 | +- Editor tooling files (VSCode IntelliSense, YAML intelligence) |
| 70 | + |
| 71 | +### Running Tests |
| 72 | + |
| 73 | +Tests live in `tests/` and require R, Python, and Julia. See `.claude/rules/testing/overview.md` for commands, test types, dependencies, and debugging tips. |
| 74 | + |
| 75 | +```bash |
| 76 | +cd tests |
| 77 | +./run-tests.sh smoke/render/render.test.ts # Linux/macOS |
| 78 | +.\run-tests.ps1 smoke/render/render.test.ts # Windows |
| 79 | +``` |
| 80 | + |
| 81 | +### Feature Format Matrix |
| 82 | + |
| 83 | +The feature format matrix in `dev-docs/feature-format-matrix/` documents and tests feature support across all output formats. |
| 84 | + |
| 85 | +- Test documents organized by feature in `qmd-files/` subdirectories |
| 86 | +- Quality ratings in format metadata: `0` (broken/partial), `1` (good), `2` (excellent) |
| 87 | +- Runs on CI via `.github/workflows/test-ff-matrix.yml` |
| 88 | + |
| 89 | +## Architecture |
| 90 | + |
| 91 | +### Entry Point & Commands |
| 92 | + |
| 93 | +- `src/quarto.ts` - Main CLI entry point |
| 94 | +- `src/command/command.ts` - Command registration |
| 95 | +- Commands are organized in `src/command/*/cmd.ts` files: |
| 96 | + - `render/` - Core rendering functionality |
| 97 | + - `preview/` - Live preview server |
| 98 | + - `publish/` - Publishing to various platforms |
| 99 | + - `create/` and `add/` - Project/extension scaffolding |
| 100 | + - `tools/`, `install/`, `check/` - Utilities |
| 101 | + |
| 102 | +### Core Systems |
| 103 | + |
| 104 | +**Project System** (`src/project/`) |
| 105 | + |
| 106 | +- `types/` - Project type implementations (book, website, manuscript, etc.) |
| 107 | +- Project types are registered via `project/types/register.ts` |
| 108 | +- Each type defines metadata, rendering behavior, and output structure |
| 109 | + |
| 110 | +**Format System** (`src/format/`) |
| 111 | + |
| 112 | +- Format handlers for different output types (HTML, PDF, DOCX, reveal.js, etc.) |
| 113 | +- `formats.ts` - Format registry and resolution |
| 114 | +- `format-handlers.ts` - Common format handling logic |
| 115 | + |
| 116 | +**Filter System** (`src/resources/filters/`) |
| 117 | + |
| 118 | +- Lua filters process Pandoc AST during rendering |
| 119 | +- `main.lua` - Entry point for filter chain |
| 120 | +- Organized by function: `crossref/`, `layout/`, `quarto-pre/`, `quarto-post/`, `quarto-finalize/` |
| 121 | +- Custom AST nodes in `customnodes/` |
| 122 | +- Common utilities in `common/` |
| 123 | + |
| 124 | +**Execution Engines** (`src/execute/`) |
| 125 | + |
| 126 | +- Integration with Jupyter, Knitr, and Observable for code execution |
| 127 | +- Engine-specific handling for Python, R, Julia, and JavaScript |
| 128 | + |
| 129 | +**Resources** (`src/resources/`) |
| 130 | + |
| 131 | +- Static assets, templates, and bundled libraries |
| 132 | +- Format-specific resources (HTML, PDF, reveal.js templates) |
| 133 | +- Extensions (Confluence, Docusaurus, etc.) |
| 134 | +- Pandoc datadir customizations |
| 135 | + |
| 136 | +### Key Subsystems |
| 137 | + |
| 138 | +**Preview System** (`src/preview/`) |
| 139 | + |
| 140 | +- Development server with live reload |
| 141 | +- Watches for file changes and re-renders |
| 142 | + |
| 143 | +**Publishing System** (`src/publish/`) |
| 144 | + |
| 145 | +- Platform-specific publishers (Netlify, GitHub Pages, Confluence, etc.) |
| 146 | +- Account management and deployment logic |
| 147 | + |
| 148 | +**Extension System** (`src/extension/`) |
| 149 | + |
| 150 | +- Quarto extensions (filters, formats, shortcodes) |
| 151 | +- Extension discovery, installation, and management |
| 152 | + |
| 153 | +### Package/Distribution |
| 154 | + |
| 155 | +- `package/` - Packaging and distribution scripts |
| 156 | +- `package/src/quarto-bld` - Build orchestration script (TypeScript) |
| 157 | +- Platform-specific packaging in `package/src/{linux,macos,windows}/` |
| 158 | + |
| 159 | +## Development Patterns |
| 160 | + |
| 161 | +### Debugging Flaky Tests |
| 162 | + |
| 163 | +Comprehensive methodology for debugging flaky tests documented in [dev-docs/debugging-flaky-tests.md](../dev-docs/debugging-flaky-tests.md). |
| 164 | + |
| 165 | +Key phases: |
| 166 | +1. Reproduce locally (outside CI) |
| 167 | +2. Binary search to isolate culprit test |
| 168 | +3. Narrow down within test file |
| 169 | +4. Understand state change |
| 170 | +5. Identify root cause |
| 171 | +6. Verify solution |
| 172 | + |
| 173 | +### TypeScript/Deno Conventions |
| 174 | + |
| 175 | +- Use Deno-native APIs (avoid Node.js APIs) |
| 176 | +- Import maps resolve dependencies (see `src/import_map.json`) |
| 177 | +- Cliffy library used for CLI parsing |
| 178 | +- File paths in imports must include `.ts` extension |
| 179 | + |
| 180 | +### Lua Filter Development |
| 181 | + |
| 182 | +- Filters run during Pandoc processing pipeline |
| 183 | +- Use `quarto` Lua module for Quarto-specific APIs |
| 184 | +- Common utilities in `src/resources/filters/common/` |
| 185 | +- Filters are chained together in `main.lua` |
| 186 | +- Documentation: <https://quarto.org/docs/extensions/lua-api.html> |
| 187 | + |
| 188 | +### Adding New Commands |
| 189 | + |
| 190 | +1. Create command file in `src/command/<name>/cmd.ts` |
| 191 | +2. Export command using Cliffy's `Command` API |
| 192 | +3. Register in `src/command/command.ts` |
| 193 | + |
| 194 | +### Adding New Project Types |
| 195 | + |
| 196 | +1. Create implementation in `src/project/types/<name>/` |
| 197 | +2. Implement `ProjectType` interface |
| 198 | +3. Register in `src/project/types/register.ts` |
| 199 | + |
| 200 | +### Adding New Formats |
| 201 | + |
| 202 | +1. Create format definition in `src/format/<name>/` |
| 203 | +2. Implement format handler |
| 204 | +3. Register in `src/format/imports.ts` |
| 205 | + |
| 206 | +### LaTeX Error Detection |
| 207 | + |
| 208 | +LaTeX error pattern maintenance is documented in [dev-docs/tinytex-pattern-maintenance.md](../dev-docs/tinytex-pattern-maintenance.md). |
| 209 | + |
| 210 | +- Patterns inspired by TinyTeX's comprehensive regex.json |
| 211 | +- Automated daily verification workflow checks for TinyTeX pattern updates |
| 212 | +- Pattern location: `src/command/render/latexmk/parse-error.ts` |
| 213 | +- Verification workflow: `.github/workflows/verify-tinytex-patterns.yml` |
| 214 | + |
| 215 | +## Important Conventions |
| 216 | + |
| 217 | +- Main branch: `main` |
| 218 | +- Version defined in `configuration` file in `QUARTO_VERSION` field |
| 219 | +- Binary dependencies (Deno, Pandoc, etc.) versions in `configuration` |
| 220 | +- Use `quarto-bld` for build operations, not direct Deno commands |
| 221 | +- Lua filters use Pandoc's filter infrastructure |
| 222 | +- TypeScript types for Lua APIs in `src/resources/lua-types/` |
| 223 | + |
| 224 | +### Changelog Conventions |
| 225 | + |
| 226 | +- Changelog files live in `news/changelog-{version}.md` (e.g., `changelog-1.9.md`) |
| 227 | +- Check `configuration` file for current `QUARTO_VERSION` |
| 228 | +- See `.claude/rules/changelog.md` for comprehensive conventions (section hierarchy, entry format, backports, regression fixes) |
| 229 | + |
| 230 | +## Key File Paths |
| 231 | + |
| 232 | +- Quarto binary: `package/dist/bin/quarto` (Linux/macOS) or `package/dist/bin/quarto.cmd` (Windows) |
| 233 | +- Deno binary: `package/dist/bin/tools/<arch>/deno` |
| 234 | +- Distribution output: `package/dist/` |
| 235 | +- Vendored dependencies: `src/vendor/` |
| 236 | + |
| 237 | +## Documentation |
| 238 | + |
| 239 | +- Documentation is at <https://quarto.org> with a sitemap at <https://quarto.org/sitemap.xml> |
| 240 | +- Prerelease docs: <https://prerelease.quarto.org/> for features in dev versions |
| 241 | +- Dev documentation in `dev-docs/` includes: |
| 242 | + - Checklists for releases and backports |
| 243 | + - Dependency update procedures |
| 244 | + - Internals guides |
| 245 | + - Performance monitoring |
| 246 | + |
| 247 | +## Contributing |
| 248 | + |
| 249 | +See CONTRIBUTING.md for pull request guidelines. Significant changes require a signed contributor agreement (individual or corporate). |
| 250 | + |
| 251 | +## Maintaining Memory Files |
| 252 | + |
| 253 | +This project uses Claude Code memory files for AI-assisted development. When updating memory files: |
| 254 | + |
| 255 | +- **Add new feature area?** Create `.claude/rules/<feature>/feature-name.md` with `paths:` frontmatter |
| 256 | +- **Update existing feature?** Edit the relevant rule file |
| 257 | +- **Deep dive doc needed?** Place it in `llm-docs/` and reference from rules |
| 258 | + |
| 259 | +**Memory file types:** |
| 260 | + |
| 261 | +| Location | When Loaded | Use For | |
| 262 | +|----------|-------------|---------| |
| 263 | +| `.claude/CLAUDE.md` | Always | Project overview, essential commands | |
| 264 | +| `.claude/rules/<feature>/` | When paths match | Feature-specific conventions | |
| 265 | +| `llm-docs/` | When explicitly read | Architectural deep dives | |
| 266 | + |
| 267 | +**Personal overrides:** Create `CLAUDE.local.md` (gitignored) for personal preferences like preferred shell syntax or workflow customizations. This file is loaded alongside the project CLAUDE.md but won't be committed. |
| 268 | + |
| 269 | +For setup details, see [dev-docs/claude-code-setup.md](../dev-docs/claude-code-setup.md). |
| 270 | + |
| 271 | +## Additional Resources |
| 272 | + |
| 273 | +- **LLM Documentation**: `llm-docs/` contains AI-specific guidance for working with the codebase |
| 274 | +- **Rules Files**: `.claude/rules/` contains conditional guidance for specific file patterns |
| 275 | +- **DeepWiki**: <https://deepwiki.com/quarto-dev/quarto-cli> for AI-indexed documentation |
0 commit comments