gbdraw
CLAUDE.md162 starsChanged 15 days agoMITView on GitHub
AGENTS.md, imported above, holds the rules every agent follows: branching, pull-request base and contents, when not to auto-merge, workspace cleanup, and browser checks. gbdraw is a Python bioinformatics tool for creating publication-quality genome diagrams from microbial genomes and organelles. It generates circular and linear visualizations of genomic features (CDS, tRNA, regulatory elements, etc.) with optional GC content/skew plots and BLAST comparison tracks. Browser and Playwright availability checks are in AGENTS.md. - Project skills live in .claude/skills/ and subagent definitions in…
- Installs packages
We split this CLAUDE.md into the rules it gives an agent
16 rules. About 0 are common, 10 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 79
Run test suites whose output is long (Playwright, the full pytest suite) through .claude/scripts/run_quiet.py, which keeps the full log in …
- Distinctive: line 85
When compacting, keep: the task goal and its done criteria.
- Distinctive: line 144
Prefer a few stable, composable contracts over mode- or surface-specific branches.
- Distinctive: line 147
Avoid repeated I/O or computation in shared layers, and protect material performance changes with measurements.
- Distinctive: line 163
Keep the current writer format even before it reaches main.
- Distinctive: line 182
Keep files unrelated to the requested work out of scope.
- Very specific: line 184
Treat Gallery sessions, source SVGs, rendered examples, thumbnails, and examples.json as generator-owned outputs.
- Very specific: line 224
Logging: Use logging module (logger = logging.getLogger(__name__))
- Very specific: line 242
Treat a change to either as a code change, and use only names importable at run time in them, not names imported under TYPE_CHECKING.
- Distinctive: line 249
Default settings for canvas dimensions, track types, feature styling, etc.
- Very specific: line 281
Slow tests: Run only in release acceptance (a workflow_dispatch of Tests on dev with the release profile), not on pull requests or ordinary …
- Distinctive: line 298
CairoSVG is optional: - only needed for non-SVG export formats
- Distinctive: line 307
When intentional changes affect SVG output, reference files need updating:
- Distinctive: line 330
Use the fewest public pages that answer distinct reader questions.
- Very specific: line 332
Before adding a public page, record the reader question, the existing owner, and a keep, merge, delete, or new disposition.
- Distinctive: line 343
Keep user- and maintainer-facing prose concise, concrete, and technically accurate.
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 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.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
@AGENTS.md
AGENTS.md, imported above, holds the rules every agent follows: branching,
pull-request base and contents, when not to auto-merge, workspace cleanup, and
browser checks.
Project Overview
gbdraw is a Python bioinformatics tool for creating publication-quality genome diagrams from microbial genomes and organelles. It generates circular and linear visualizations of genomic features (CDS, tRNA, regulatory elements, etc.) with optional GC content/skew plots and BLAST comparison tracks.
- Version: 0.14.5
- Python: ≥3.10
- Output formats: SVG, PNG, PDF, EPS, PS
Quick Commands
# Run tests (fast, excludes slow tests)
pytest tests/ -v -m "not slow"
# Run all tests including slow
pytest tests/ -v
# Compare generated SVGs with tracked references (read-only)
pytest tests/test_output_comparison.py::TestOutputComparison -v
# Update tracked references only for an intentional, reviewed geometry change
pytest tests/test_output_comparison.py::TestGenerateReferences --update-reference-outputs -v
# Run a single test file
pytest tests/test_regression.py -v
# Run a single test by name
pytest tests/ -v -k "circular_basic"
# Run tests by marker
pytest tests/ -v -m "circular"
pytest tests/ -v -m "linear"
# Run with coverage
pytest tests/ --cov=gbdraw --cov-report=html
# Check code formatting (ruff)
ruff check gbdraw/
# Type-check gbdraw/ with the pinned mypy and compare with the type-debt baseline
pytest tests/test_type_check_ratchet.py
mypy # full error list
# Install in development mode
pip install -e ".[dev]"
# Prepare the generated browser wheel for offline web packaging/tests
python tools/prepare_browser_wheel.py
# Prepare the hosted bundle (wheel URL carries the wheel's content hash)
python tools/prepare_cloudflare_pages.py
# Build distribution
python -m build
# Basic usage examples
gbdraw circular --gbk genome.gb -o output
gbdraw linear --gbk genome1.gb genome2.gb -b blast.txt -o comparison
gbdraw gui # Launch web UIBrowser and Playwright availability checks are in AGENTS.md.
Agent skills and subagents
- Project skills live in
.claude/skills/and subagent definitions in.claude/agents/. A skill describes a procedure; selecting one never widens the task's scope or adds surfaces to it. - Run test suites whose output is long (Playwright, the full pytest suite)
through
.claude/scripts/run_quiet.py, which keeps the full log in a file and prints a short summary with the exit status preserved.
Compact instructions
When compacting, keep: the task goal and its done criteria; open PR numbers
with head SHAs and CI state; branch and worktree paths; Owner decisions and
Owner-delegated choices not yet written to a file; bug IDs assigned in this
session; and the path of the task's STATE.md. Drop file contents, command
output, and passing test logs that can be read again.
Project Structure
gbdraw/
├── gbdraw/ # Main package
│ ├── cli.py # CLI entry point (gbdraw command)
│ ├── circular.py # Circular diagram CLI handler
│ ├── linear.py # Linear diagram CLI handler
│ ├── api/ # Public programmatic API
│ ├── canvas/ # Canvas configuration (dimensions, layout)
│ ├── config/ # Configuration loading (TOML parsing)
│ ├── configurators/ # Feature/GC/Legend/BLAST configurators
│ ├── core/ # Core utilities (sequences, colors, text)
│ ├── diagrams/ # Diagram assembly (circular/, linear/)
│ ├── features/ # Feature objects, coordinates, colors, tracks
│ ├── io/ # Input/output (genome loading, color tables)
│ ├── labels/ # Label handling & filtering
│ ├── legend/ # Legend generation
│ ├── render/ # SVG rendering (drawers/, groups/, export)
│ ├── data/ # Built-in data (config.toml, color_palettes.toml, fonts)
│ └── web/ # Web app (SPA, no build step)
│ ├── index.html # Entry point, templates, CSP, CSS
│ └── js/ # ES modules (app.js entry, app/ with feature subfolders, services/, utils/)
├── tests/ # Test suite (pytest)
│ ├── reference_outputs/ # Reference SVG files for comparison
│ └── utils/ # Test utilities
├── docs/ # Documentation
├── examples/ # Example files (GenBank, FASTA, BLAST)
└── pyproject.toml # Package configurationKey Architecture
Entry Points
- CLI:
gbdraw.cli:main()→ dispatches tocircularorlinearsubcommands - Beginner-facing Python API: the
gbdrawpackage root exportsread_genbank(),read_gff(),draw_circular(),draw_linear(), mode-specific option types, andDiagram. - Typed integration API:
gbdraw.apiexports typed request, render, session, table, option, and track-slot contracts plus explicit render helpers.
Low-level assemblers remain in gbdraw.api.diagram for internal engine use.
Canvas and drawing configurators remain implementation details in their owner
modules; they are not re-exported from gbdraw.api.
Architecture changes should keep these entry points convergent:
- Route the Python API, CLI, Web UI, and both diagram modes through the same typed core/planner; adapters should only translate surface-specific input and output.
- As a default, add an abstraction only when it unifies at least two real execution paths and removes the superseded paths in the same change. Extend existing boundaries instead of creating parallel pipelines.
- Prefer a few stable, composable contracts over mode- or surface-specific branches. Add capabilities as data at an existing boundary when practical, so later extension or removal does not multiply change points.
- Avoid repeated I/O or computation in shared layers, and protect material performance changes with measurements.
Architecture-bearing changes must follow the architecture fitness-function ratchet. Ordinary non-increasing changes record concise owner/path evidence and remove superseded paths. Complete before/after OE, PE, and CB sets plus a separate maintainer decision are required only for the exception conditions defined by that policy.
Persisted-format compatibility
- Compatibility readers and migrators require evidence that the old contract
existed in the first-parent history of
mainor in a release tag, plus a representative positive fixture. Track session, request, cache, metadata, and other schema namespaces separately. - Keep the current writer format even before it reaches
main. If an active branch advances that format again, rewrite branch-owned artifacts to the newest format before merge and remove the superseded reader, migrator, fixture, test, and user documentation. Do not chain migrations through, or advertise, intermediate versions that never reachedmain. - A breaking Session change raises
SESSION_VERSIONby one overmain's; until that version reachesmain, later breaking changes keep it and rewrite its history entry and fixtures. The unit ismain, not a release tag. - A change to the generated contracts in
gbdraw/web/js/contracts/needs the history, reference, and fixture co-changes that the Gate checks; see Persisted contract co-change.
Working-tree overwrite policy
- Uncommitted state is not a preservation requirement in this repository. When an in-scope fix conflicts with dirty code, tests, documentation, fixtures, or generated artifacts, replace the uncommitted implementation as needed to make the result correct and internally consistent.
- Inspect the existing diff before editing so the replacement is deliberate. Keep files unrelated to the requested work out of scope; this policy does not authorize broad cleanup or deletion elsewhere in the working tree.
- Treat Gallery sessions, source SVGs, rendered examples, thumbnails, and
examples.jsonas generator-owned outputs. A requested Gallery refresh may overwrite dirty copies directly; regenerate them from the current code and declared inputs instead of merging or preserving their previous bytes.
Data Flow
- Input: GenBank/GFF3+FASTA files
- Loading:
gbdraw.io.genome.load_gbks() - Configuration: TOML config → dataclass models (
GbdrawConfig) - Assembly:
gbdraw.diagramscombines features, GC plots, labels - Rendering:
gbdraw.rendergenerates SVG viasvgwrite - Export:
gbdraw.render.exportsaves to various formats (CairoSVG optional)
Configurators Pattern
Main configurator classes encapsulate drawing logic:
FeatureDrawingConfigurator- Genomic featuresGcContentConfigurator- GC content trackGcSkewConfigurator- GC skew trackBlastMatchConfigurator- BLAST comparison (linear only)LegendDrawingConfigurator- Color legend
Render Module Structure
The gbdraw/render/ module has a two-tier architecture:
- drawers/: Low-level SVG element builders (individual shapes, paths)
- groups/: High-level SVG group assemblers that compose drawers
- export.py: Internal format parsing and deprecated lenient export compatibility
Web UI Structure
gbdraw/web/index.htmlis the SPA entry point (HTML/CSS/templates + CSP) and loadsgbdraw/web/js/app.js.- JavaScript is split into ES modules under
gbdraw/web/js/(state.js,config.js,components.js,services/,utils/,app/). Larger UI modules are grouped undergbdraw/web/js/app/subfolders (for examplelegend/,legend-layout/,feature-editor/) while the top-levelapp/*.jsfiles keep thecreate*entry points.
Coding Conventions
Style
- Type hints: Extensively used with
from __future__ import annotations - Naming: snake_case (functions/modules), PascalCase (classes), UPPER_SNAKE_CASE (constants)
- Logging: Use
loggingmodule (logger = logging.getLogger(__name__))
Patterns
- Frozen dataclasses for configuration models
- Factory methods (
.from_dict()) for config parsing NamedTuplefor immutable data structures
Type checking
- The type-debt rule for
gbdraw/(mypy,TYPE_DEBT_BASELINEintests/test_type_check_ratchet.py) is "Type checking" in the architecture ratchet. In short: a file's mypy errors plus# type: ignorecomments stay at or below its entry, a new file has none, and adding or raising an entry needs the Owner's approval. - Class-body annotations are runtime data.
get_type_hintsreads dataclass fields ingbdraw/config/modify.py(config overrides) andgbdraw/session_request_codec.py(canonical request validation), andtests/test_public_contract.pyhashes the signatures ofgbdraw.__all__. Treat a change to either as a code change, and use only names importable at run time in them, not names imported underTYPE_CHECKING. - Plan:
docs/internal/PYTHON_TYPE_CHECK_RATCHET_PLAN_2026-10-06.md.
Key Configuration Files
gbdraw/data/config.toml
Default settings for canvas dimensions, track types, feature styling, etc.
gbdraw/data/color_palettes.toml
Predefined color palettes for feature visualization.
pyproject.toml
Package configuration, test markers, coverage settings.
Testing
Test Markers
@pytest.mark.slow # Skip in fast runs
@pytest.mark.regression # Regression tests
@pytest.mark.circular # Circular diagram tests
@pytest.mark.linear # Linear diagram testsReference Output Tests
Tests compare generated SVG against tests/reference_outputs/ files.
Test Helpers (tests/conftest.py)
GbdrawRunner.run()- Run either diagram subcommand with optional BLAST inputsfind_test_inputfixture - Find test inputs across repository and optional local directoriestmp_path- Built-in pytest fixture for isolated test outputs
CI/CD
- Python versions tested: 3.10, 3.11, 3.12 (3.13 and 3.14 also in the dev-tier Core matrix)
- Lint job: Installs the Ruff version pinned in the
devextra ofpyproject.tomland blocks CI on lint failures - Type check:
Core PRandCoreinstall thetypecheckextra and runtests/test_type_check_ratchet.py(mypy 2.4.0) with the other core tests - CairoSVG: The Core jobs install the
exportextra (cairosvg) withtypecheck; no workflow installs extra system packages - Slow tests: Run only in release acceptance (a
workflow_dispatchof Tests ondevwith the release profile), not on pull requests or ordinary pushes
Dependencies
Core
- BioPython - Genome file parsing
- svgwrite - SVG generation
- pandas - Data manipulation
- fonttools - Font metrics
- bcbio-gff - GFF3 parsing
Optional
- cairosvg - PNG/PDF/EPS/PS export (requires
libcairo2-dev libpango1.0-devon Ubuntu)
Important Notes
- Python 3.10+ required due to
from __future__ import annotations - CairoSVG is optional - only needed for non-SVG export formats
- Track types: "spreadout", "middle", "tuckin" control circular diagram layout
- Genome size thresholds: Window/step sizes auto-adjust (<1M, 1-10M, >10M bp)
- Label filtering: Supports priority files, blacklists, whitelists
- BLAST comparison: Linear diagrams only, requires outfmt 6/7
- Browser wheel workflow:
gbdraw/web/gbdraw-<version>-py3-none-any.whlis a generated, gitignored asset. Prepare it before wheel-dependent web packaging checks or distribution builds.
Updating Reference Outputs
When intentional changes affect SVG output, reference files need updating:
# 1. Run comparison tests to identify intentional differences. Actual output is
# retained under pytest's temporary directory, not reference_outputs/.
pytest tests/test_output_comparison.py::TestOutputComparison -v
# 2. Review the differences and regenerate only after approving the change.
pytest tests/test_output_comparison.py::TestGenerateReferences \
--update-reference-outputs -v
# 3. Review the tracked SVG diff and verify the new references.
git diff -- tests/reference_outputs/
pytest tests/test_output_comparison.py::TestOutputComparison -vWithout --update-reference-outputs, reference-generation tests are skipped and
normal test runs do not write to tests/reference_outputs/.
Documentation
- Public documentation has four teaching routes: Tutorials, Technical
documentation, FAQ, and Gallery.
docs/DOCS.mdis the navigation authority. - Use the fewest public pages that answer distinct reader questions. Coverage does not require one page per capability, workflow, or interface.
- Before adding a public page, record the reader question, the existing owner,
and a
keep,merge,delete, ornewdisposition. Add a page only when editing an existing owner cannot answer the question clearly. - A Tutorial needs a deliberate learning progression to a finished result. Separate GUI, CLI, or Python evidence does not by itself justify separate public pages.
- Technical documentation owns exact behavior and contracts. FAQ owns concise decisions and troubleshooting, and links to the technical owner. Gallery is for discovering finished outcomes.
- Executable scenarios may support one public page or no public page. Do not turn an evidence inventory into a public-page inventory.
- Keep user- and maintainer-facing prose concise, concrete, and technically accurate. Optimize internal implementation plans for execution fidelity.
- Preserve exact technical terms, UI labels, CLI options, identifiers, and scientifically necessary qualifications.
- Main docs:
docs/DOCS.md - Canonical tutorial index:
docs/TUTORIALS/README.md - Current documentation plan:
docs/internal/DOCUMENTATION_RESTRUCTURE_PLAN_2026-10-09.md, which keeps the routes and evidence architecture ofdocs/internal/DOCUMENTATION_SIMPLIFICATION_IMPLEMENTATION_PLAN_2026-08-09.md - CLI Reference:
docs/CLI_Reference.md - Web app development: See
gbdraw/web/CLAUDE.mdfor web-specific guidance - Web app: https://gbdraw.app/
- GitHub: https://github.com/satoshikawato/gbdraw
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- avoid-ai-writingSkill
- gbdraw-campaignSkill
- gbdraw-promotionSkill
- gbdraw-ship-prSkill
- gbdraw-videoSkill
- gbdraw-worktreeSkill
- love-me-love-my-docsSkill
- translate-web-uiSkill
- web-gallery-screenshot-maintenanceSkill
- write-clear-pull-requestSkill
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
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.

