agentleFS
diegoscarabellidiegoscarabelli/garmin-health-data/CLAUDE.md

garmin-health-data

CLAUDE.md122 starsChanged 14 months agoApache-2.0View on GitHub

The most important source of truth is the /README.md file, which contains the latest information about the project. You MUST read and understand the README.md file in order to provide accurate and relevant responses and coding assistance. The README.md file includes: - Introduction: Project overview, objectives, and features for extracting Garmin Connect health data to a local SQLite database. - Features: Comprehensive data extraction, automatic deduplication, FIT file processing, and flexible authentication. - Installation: Installation instructions via pip or from…

  • Installs packages

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

19 rules. About 0 are common, 10 are distinctive, and 9 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.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use SQLFluff to format the DDL file (configured in pyproject.toml):

    line 38
  2. Distinctive:

    When modifying the schema:

    line 45
  3. Very specific:

    Update tables.ddl with new/modified table definitions.

    line 46
  4. Very specific:

    Update corresponding SQLAlchemy model in models.py to match.

    line 47
  5. Distinctive:

    Autoflake: Remove unused imports and variables.

    line 82
  6. Very specific:

    Docstring format: Use :param and :return format.

    line 85
  7. Distinctive:

    Before completing any code changes:

    line 95
  8. Very specific:

    Test naming: Use test_* pattern for test functions.

    line 126
  9. Distinctive:

    Fixtures: Use pytest fixtures for common setup.

    line 128
  10. Distinctive:

    When working with authentication code:

    line 132
  11. Distinctive:

    Use environment variables or secure credential storage.

    line 134
  12. Very specific:

    Follow existing patterns in garmin_health_data/auth.py.

    line 135
  13. Distinctive:

    When adding new data processors:

    line 140
  14. Very specific:

    Use SQLAlchemy models from models.py.

    line 142
  15. Distinctive:

    Use upsert patterns for deduplication.

    line 145
  16. Very specific:

    Don't pass triple-quoted strings to sqlalchemy.text(...): docformatter may treat them as docstrings and append a period (DO NOTHING becomes …

    line 149
  17. Distinctive:

    When modifying CLI commands:

    line 153
  18. Very specific:

    Use Click framework (existing in garmin_health_data/cli.py).

    line 154
  19. Distinctive:

    Follow existing command structure and naming conventions.

    line 157

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

README.md

The most important source of truth is the /README.md file, which contains the latest information about the project. You MUST read and understand the README.md file in order to provide accurate and relevant responses and coding assistance.

The README.md file includes:

  • Introduction: Project overview, objectives, and features for extracting Garmin Connect health data to a local SQLite database.
  • Features: Comprehensive data extraction, automatic deduplication, FIT file processing, and flexible authentication.
  • Installation: Installation instructions via pip or from source.
  • Quick Start: Authentication setup and basic usage examples.
  • Usage: Detailed commands for data extraction, initialization, and status checking.
  • Data Categories: Complete list of available data types with extraction frequency.
  • Database Schema: Schema documentation with inline comments, SQLite adaptations, and table structure.
  • Repository Structure: Overview of code organization (garmin_health_data/, tests/).
  • Development: Setup instructions for contributors.
  • Comparisons: Feature comparison with other tools (garmindb, garmy, etc.).

Database Schema Architecture

Following the openetl pattern, the database schema is defined in garmin_health_data/tables.ddl:

  • tables.ddl: Single source of truth for database schema with inline SQL comments.
  • models.py: SQLAlchemy ORM models for data processing ONLY (not schema generation).
  • db.py: Executes tables.ddl to create schema automatically.

Schema Documentation

Inline comments in tables.ddl are preserved in the SQLite database and can be viewed:

sqlite3 garmin_data.db "SELECT sql FROM sqlite_master WHERE type='table' AND name='activity';"

Formatting DDL Files

Use SQLFluff to format the DDL file (configured in pyproject.toml):

python -m sqlfluff fix garmin_health_data/tables.ddl

Making Schema Changes

When modifying the schema:

  1. Update tables.ddl with new/modified table definitions.
  2. Update corresponding SQLAlchemy model in models.py to match.
  3. Format with SQLFluff.
  4. Users must re-initialize the database or manually apply changes.

Code Execution Environment

This project uses standard Python packaging with development dependencies specified in pyproject.toml.

Installation

# Install package in development mode
pip install -e ".[dev]"

Running Tests

# Run all tests with coverage
pytest

# Run specific test file
pytest tests/test_processor.py

# Run with verbose output
pytest -v

Formatting Standards

This project follows the same code quality standards as openetl:

Python Formatting

  • Black: Line length 88, Python 3.9+ target.
  • Autoflake: Remove unused imports and variables.
  • Docformatter: Format docstrings consistently.
  • Type hints: Required for all function parameters and return values.
  • Docstring format: Use :param and :return format.

SQL Formatting

  • SQLFluff: Format SQL files (configured in pyproject.toml).
  • Dialect: SQLite.
  • Style: Leading commas, 88 character line length.

Quality Checklist

Before completing any code changes:

  • Module docstring present
  • Imports properly organized and sorted, no unused imports
  • All functions have type hints
  • All docstrings use :param and :return format
  • Proper spacing and blank lines throughout file
  • Black-compliant format
  • No trailing whitespace
  • Consistent indentation (4 spaces)
  • Periods at the end of ALL sentences (comments, docstrings, log messages)
  • No line longer than 88 characters
  • Final newline at end of file

Automated Formatting

Format Python files:

python -m black garmin_health_data/
python -m autoflake --in-place --remove-all-unused-imports -r garmin_health_data/
python -m docformatter --in-place -r garmin_health_data/

Format SQL files:

python -m sqlfluff fix garmin_health_data/tables.ddl

Testing Requirements

  • Coverage: Maintain high test coverage for all new code.
  • Test naming: Use test_* pattern for test functions.
  • Test organization: Mirror source structure in tests/ directory.
  • Fixtures: Use pytest fixtures for common setup.

Authentication Handling

When working with authentication code:

  • Never hardcode credentials.
  • Use environment variables or secure credential storage.
  • Follow existing patterns in garmin_health_data/auth.py.
  • Respect token expiration and refresh logic.

Data Processing Patterns

When adding new data processors:

  • Follow existing patterns in garmin_health_data/processor.py.
  • Use SQLAlchemy models from models.py.
  • Implement proper error handling and logging.
  • Handle NULL values and missing data gracefully.
  • Use upsert patterns for deduplication.

Raw SQL Strings (docformatter Footgun)

Don't pass triple-quoted strings to sqlalchemy.text(...): docformatter may treat them as docstrings and append a period (DO NOTHING becomes DO NOTHING.), corrupting the SQL. Use implicitly concatenated regular string literals instead. See #44 / #45.

CLI Development

When modifying CLI commands:

  • Use Click framework (existing in garmin_health_data/cli.py).
  • Provide helpful error messages.
  • Include progress indicators for long-running operations.
  • Follow existing command structure and naming conventions.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.