AGENTS.md
Guides AI coding assistants on project structure, commands, and architecture for a Julia CommonMark library.
What this file does
Guides AI coding assistants on project structure, commands, and architecture for a Julia CommonMark library.
When to use it
- Onboarding a new contributor to the CommonMark.jl codebase
- Setting up an AI assistant to work with this specific Julia project
- Understanding the parser, writer, and extension system design
Assumes this stack
AGENTS.md
Project guidance for AI coding assistants.
Project Overview
CommonMark.jl is a Julia implementation of the CommonMark specification. It provides a modular parser, AST representation, and multiple output formats (HTML, LaTeX, Typst, Terminal, Markdown, Notebook).
Development Commands
Testing
julia --project -e 'using Pkg; Pkg.test()' # Run all tests
just test-all # Via justfile
just test-item <name> # Run specific test item
To run tests with TestItemRunner (filtered by tag, name, etc.):
julia --project <<'EOF'
using TestEnv; TestEnv.activate(); cd("test")
using TestItemRunner
@run_package_tests(filter=ti->:math in ti.tags)
EOF
Code Formatting
just format
Building
julia --project -e 'using Pkg; Pkg.instantiate(); Pkg.precompile()'
Documentation
julia --project=docs -e 'include("docs/make.jl")' # Build docs locally
Benchmarking
just bench # Run benchmarks (terminal output)
just bench-save <name> # Save results to benchmark/results/<name>.json
just bench-compare <baseline> <cur> # Compare two saved results
Key Entry Points
src/CommonMark.jl- main module, exportssrc/ast.jl- Node struct, tree operationssrc/parsers.jl- Parser struct, block/inline parsingsrc/writers.jl- output format dispatchsrc/extensions.jl- extension includes
Architecture
Core Components
-
AST (Abstract Syntax Tree): Built around
Nodetype with container hierarchyAbstractContainer→AbstractBlock/AbstractInline- Doubly-linked tree with parent/child/sibling references
- Source position tracking (
sourceposfield) - Metadata dictionary for extensibility
-
Parser System: Two-phase parsing (blocks then inlines)
- Rule-based with pluggable components
- Parser state tracks position and context
- Rules in
src/parsers/blocks/andsrc/parsers/inlines/
-
Writer System: MIME-based dispatch for output formats
- Each writer in
src/writers/(html.jl, latex.jl, etc.) - Template support via Mustache
- Environment configuration passing
- Each writer in
-
Extension System: Optional features via rule modification
- Extensions in
src/extensions/ - Enabled via parser configuration
- Maintains CommonMark compliance when disabled
- Extensions in
Key Design Patterns
- Visitor Pattern: Tree traversal via iterator protocol
- Rule Pattern: Modular parsing rules that can be enabled/disabled
- MIME Dispatch: Output format selection via Julia's MIME system
- Type Stability: Careful use of concrete types in AST
Creating New Rules
See docs/src/developing.md for internal documentation on writing extension rules. Covers AST nodes, parser hooks, and writer functions.
Testing Strategy
- CommonMark spec compliance tested against
test/spec.json - Unit tests for each component
- Integration tests in
test/integration.jl - Sample-based testing with expected outputs in
test/samples/
What's inside
5 sections: overview, commands, entry points, architecture, testing strategy. 6 code blocks, 4 component descriptions.
Change this for your project
- Replace
MichaelHatherly/CommonMark.jlwith your own repository name - Replace
CommonMark.jlwith your package name in paths and commands - Replace
src/CommonMark.jlwith your main module file path
Where it goes
Save as AGENTS.md in your repository root. Read by Codex, Cursor and other agents that follow the AGENTS.md convention.
Worth borrowing
- Two-phase parsing (blocks then inlines) for modular rule-based parsers
- MIME-based dispatch for output format selection
- Visitor pattern for tree traversal via iterator protocol
Related Documents
Browser-only development
Guides AI assistants on an Electron + React + TypeScript desktop app for browsing and organizing AI-generated images locally.
Claude Agents — Reference & Recommendations
Catalogues 40+ Claude agents and marketing skills for building a cat adoption charity landing page, with a ready-to-paste prompt and backend API reference.
Golden DKG Prototype -- Master Plan
Defines an 8-phase implementation plan for a Rust prototype of the Golden non-interactive DKG protocol using BLS12-381 and tokio.
Swarms Examples Index
Lists 60+ example scripts for building single and multi-agent systems with the Swarms framework, organized by category and use case.