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.1.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.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cdd_utils-0.1.1.tar.gz
Algorithm Hash digest
SHA256 db067ad8dce90f38f3580cc07cb33202620fd89d87d3a8e204b9dbaba9f5440d
MD5 6400ade758bcaf7aff36a608006d828d
BLAKE2b-256 cd5e6412fe0cbaf7f8c224dbe850e63eebac601701a1ecfefb003704e05809c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cdd_utils-0.1.1-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.14.2

File hashes

Hashes for cdd_utils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2648610d5443956e920c19fe173a5f996fc44b0ef8a9da66d7166700d38c9a2d
MD5 1dc38b700cf39527c534592d04669c43
BLAKE2b-256 45298f3d5561a7725e91faa7b60a85d1b48853e5e048e3c22933b83f2f33960a

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