Skip to main content

General utilities for AI-assisted development

Project description

CDD Utils

General utilities for AI-assisted development.

Part of the Contract-Driven Development ecosystem.

┌─────────────────────────────────────────────────────────────────┐
│                                                                 │
│   cdd-flow         Orchestration layer                         │
│                    ctx, land, undo, checkpoint                  │
│      │                                                          │
│      ├───────────► cdd-context     Context generation           │
│      │                             PROJECT_CONTEXT.md           │
│      │                                                          │
│      └───────────► cdd-tooling     Verification                 │
│                    analyze, lint, test, compare                 │
│                                                                 │
│   cdd-utils        General utilities        ◄── YOU ARE HERE    │
│                    utf8 (encoding hygiene)                      │
│                                                                 │
│   cdd              Methodology (spec only)                      │
│                    SPEC.md, README.md                           │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Installation

pip install cdd-utils

# Or with pipx (recommended for CLI use)
pipx install cdd-utils

# From source (editable)
git clone https://github.com/thegdyne/cdd-utils.git
cd cdd-utils
pip install -e ".[dev]"

Commands

Command Description
cdd-utils utf8 UTF-8 corruption detection and ASCII normalization

utf8 - Encoding Hygiene

AI-generated code often contains encoding issues: smart quotes, corrupted UTF-8 sequences, invisible characters. The utf8 command detects and fixes these.

Modes

Mode Flag Description
Report --report Scan and list all non-ASCII characters
Preview --dry-run Show what would be fixed
Smart Preview --dry-run --smart Categorize as legitimate vs suspicious
Fix All --fix Normalize ALL non-ASCII to ASCII
Smart Fix --smart-fix Fix only suspicious (clustered) characters

Smart Mode

Smart mode distinguishes between:

  • Legitimate: Isolated non-ASCII surrounded by ASCII (intentional symbols like , , )
  • Suspicious: Clustered non-ASCII adjacent to each other (likely corruption like â†')

Examples

# Scan a directory for non-ASCII
cdd-utils utf8 --report src/

# Preview fixes for a file
cdd-utils utf8 --dry-run src/main.py

# See legitimate vs suspicious breakdown
cdd-utils utf8 --dry-run --smart src/main.py

# Fix only corrupted sequences, keep intentional Unicode
cdd-utils utf8 --smart-fix src/main.py

# Fix everything (normalize all to ASCII)
cdd-utils utf8 --fix src/main.py

# Filter by extension
cdd-utils utf8 --report src/ --ext .py .scd

What It Detects

  • Invalid/corrupted UTF-8 byte sequences
  • Smart quotes and curly apostrophes (" " ' ')
  • Em/en dashes and fancy hyphens ( )
  • Non-breaking spaces and zero-width characters
  • Unicode arrows, bullets, symbols
  • Replacement characters (corruption indicator)

Backups

Both --fix and --smart-fix create timestamped backups before modifying files:

_utf8_backups_20250101_120000/
├── src/
│   └── main.py

Suggested Alias

alias cu='cdd-utils'
# Usage: cu utf8 --report src/

Development

git clone https://github.com/thegdyne/cdd-utils.git
cd cdd-utils
pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdd_utils-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdd_utils-0.1.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file cdd_utils-0.1.0.tar.gz.

File metadata

  • Download URL: cdd_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for cdd_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f42d7aa1fce3f22339c21cb35f1a144d6666c55887d1bc7fac6a5cc9800dbf6
MD5 2aa1a085c373b99090c1f7189cdc33f3
BLAKE2b-256 e90e1e77f127f4554b496896b7a9dd2b473bdb910e807db0ee1711ca74a7578f

See more details on using hashes here.

File details

Details for the file cdd_utils-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cdd_utils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for cdd_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0243f1cc8c7d6d0109b6d9a82939a26a33fdc4d9a5861d3fe7ebb08f2a1111d8
MD5 c628908167c51b61c44bf701642db6f0
BLAKE2b-256 d281ea0c6ef37c1250421da84ef93ba1e78326f1eee7fcbd39bc42a6dcf7bd92

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page