feat: Language-Agnostic Global CLAUDE.md with TypeScript Auditor#2
Merged
feat: Language-Agnostic Global CLAUDE.md with TypeScript Auditor#2
Conversation
## Summary Implements a language-agnostic global CLAUDE.md and specialized TypeScript auditor to maintain universal design while preserving language-specific expertise. ## Changes ### 1. Language-Agnostic Global CLAUDE.md - Created `src/claude/CLAUDE.md` with language-neutral engineering principles - Stripped TypeScript-specific syntax, kept universal concepts - Covers Result types, DI, immutability, pure functions (conceptually) - Includes critical anti-patterns (NO FAKE SOLUTIONS, FAIL HONESTLY) - Code quality enforcement (root cause analysis, not workarounds) - ~330 lines of precise, non-bloated global instructions ### 2. TypeScript Auditor Agent - Created `src/claude/agents/devflow/audit-typescript.md` - Conditional execution: runs only if .ts/.tsx files changed OR tsconfig.json exists - Built-in detection logic (gracefully skips non-TS projects) - Audits: type safety config, any usage, type assertions, branded types, discriminated unions, immutability, Result types, naming conventions, dependency injection, pure functions - Outputs: CRITICAL/HIGH/MEDIUM/LOW severity with file:line references ### 3. Smart CLAUDE.md Mounting - Updated `src/cli/commands/init.ts` with intelligent mounting logic - **Fresh install**: Directly installs CLAUDE.md (no conflicts) - **Existing file**: Preserves user's CLAUDE.md, creates CLAUDE.devflow.md - **--force flag**: Prompts for confirmation, backs up existing files - **-y flag**: Auto-approves prompts (for automation) - Parallel implementation to settings.json (consistent UX) ### 4. Pre-commit/Pre-PR Integration - Updated `src/claude/commands/devflow/pre-commit.md` - Updated `src/claude/commands/devflow/pre-pr.md` - Added audit-typescript to agent orchestration - Automatic conditional execution (no manual config needed) - Integrated into review document templates ## Key Features ### Smart Mounting - No existing CLAUDE.md → direct install - Existing CLAUDE.md → install as .devflow.md with merge instructions - Force override → backup to .backup, install DevFlow version - Clear instructions for all scenarios ### TypeScript Detection ```bash # Runs if: - .ts/.tsx files changed OR - tsconfig.json exists # Skips if neither condition met ``` ### Safety - Never overwrites without permission - Always backs up before force override - Clear warnings about what --force does - Reversible operations (backup files) ## Testing All scenarios tested locally: - ✅ Fresh install (no existing files) - ✅ Safe install (existing files preserved) - ✅ Force with prompt decline (falls back to safe) - ✅ Force with -y (auto-approved, backed up) - ✅ Custom content preservation verified ## Benefits 1. **Language-Agnostic**: Global CLAUDE.md works for any language 2. **Specialized Expertise**: TypeScript rules enforced where applicable 3. **Extensible Pattern**: Easy to add audit-python, audit-go, etc. 4. **Safe by Default**: User control over global configuration 5. **Automation-Friendly**: --force -y for scripts/CI/CD 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
dean0x
pushed a commit
that referenced
this pull request
Oct 24, 2025
…ions, async operations
Code Quality Improvements:
- Extract shared utilities to src/cli/utils/ (eliminated 65 lines of duplication)
- Created paths.ts with getInstallationPaths(), path validation, env var security
- Created git.ts with async getGitRoot() using promisified exec
- Both init.ts and uninstall.ts now use shared utilities
Security & Reliability:
- Fixed TOCTOU race conditions with atomic file operations ('wx' flag)
- settings.json, CLAUDE.md, .claudeignore now use exclusive create
- Added environment variable path validation (CLAUDE_CODE_DIR, DEVFLOW_DIR)
- Validates absolute paths, warns if outside home directory
Performance:
- Replaced execSync with async exec (non-blocking git operations)
- Eliminated redundant git root detection (was called twice)
- All file operations now async throughout the codebase
CI/CD Compatibility:
- Added TTY detection for interactive prompts
- Falls back to default scope in non-interactive environments
- Clear messaging when non-TTY detected
Documentation:
- Added comprehensive CHANGELOG entry for v0.5.0
- Documented all fixes, improvements, and breaking changes
- Migration notes for existing users
Tested:
- User scope installation: ✓
- Local scope installation: ✓
- TTY detection and fallback: ✓
- Auto-detection uninstall: ✓
- Atomic file operations: ✓
- All async operations: ✓
Closes code review issues #2, #4, #5, #6
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
dean0x
added a commit
that referenced
this pull request
Oct 24, 2025
…vements (#16) * feat: add installation scope support (global vs local) Adds --scope option to init command allowing users to choose between: - Global scope: install to ~/.claude/ (user-wide, all projects) - Local scope: install to git-root/.claude/ (project-only) Features: - Interactive prompt when --scope not provided (defaults to global) - New getInstallationPaths() function for scope-aware directory resolution - Git root detection with security validation - For local scope: creates .claude/ and .devflow/ in git repository root - For local scope: automatically adds directories to .gitignore - Updated output messages to indicate installation scope and paths - Comprehensive README documentation with examples Implementation: - getGitRoot(): Detects git repository root with validation - getInstallationPaths(scope): Returns paths based on scope - For global: uses existing ~/.claude/ and ~/.devflow/ - For local: uses <git-root>/.claude/ and <git-root>/.devflow/ - Skip Claude Code detection for local scope (create directory instead) Testing: - Global scope: Verified existing behavior maintained - Local scope: Successfully tested in devflow repository - Both scopes create all components correctly Use cases: - Global: Personal development across all projects - Local: Team projects where DevFlow should be project-specific - Local: CI/CD environments with project-scoped configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: rename "global" scope to "user" for clarity Changes all references from "global" to "user": - TypeScript types: 'global' | 'local' → 'user' | 'local' - CLI option: --scope <global|local> → --scope <user|local> - Interactive prompt: "Choose scope (global/local)" → "Choose scope (user/local)" - Output messages: "global" → "user" - README documentation: "Global Scope" → "User Scope" Rationale: "user" is clearer and more precise than "global" - "user scope" = user-wide installation (~/.claude/) - "local scope" = project-specific installation (git-root/.claude/) All functionality remains the same, only naming improved. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add scope support to uninstall command Enhanced uninstall command to support both user and local scopes: Features: - Auto-detects installed scopes (user and/or local) if --scope not specified - --scope option: user, local, or both - Uninstalls from user scope (~/.claude/, ~/.devflow/) - Uninstalls from local scope (git-root/.claude/, git-root/.devflow/) - Clear output showing which scope is being uninstalled - Handles cases where DevFlow installed in multiple scopes Auto-detection logic: - Checks ~/.claude/commands/devflow/ for user scope - Checks git-root/.claude/commands/devflow/ for local scope - If both found, uninstalls from both with notification - If none found, exits with helpful message Usage examples: - devflow uninstall (auto-detects and uninstalls from all found scopes) - devflow uninstall --scope user (explicit user scope only) - devflow uninstall --scope local (explicit local scope only) - devflow uninstall --scope both (force uninstall from both) Testing: - Verified local scope uninstall removes git-root/.claude/commands/devflow/ - Verified directories properly cleaned up - Verified error handling for non-git repositories 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: remove "both" option from uninstall, auto-detect is default Simplified uninstall command: - Removed --scope both option (excessive) - Default behavior (no --scope): auto-detect and uninstall from all found scopes - --scope user: uninstall from user scope only - --scope local: uninstall from local scope only Rationale: Default should be smart and do the right thing automatically. Users who want specific scope can use --scope flag. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: simplify settings/CLAUDE.md installation - never override Simplified file installation behavior: - Never override or rename existing files - Always install adjacent files (settings.devflow.json, CLAUDE.devflow.md) - User manually merges desired changes into their existing files Changes: - Removed complex backup/rename logic (managed-settings.json) - Removed --force and -y options (no longer needed) - Removed forceOverride logic and prompts - Simplified to simple exists check: install as .devflow.* if exists Installation behavior now: - settings.json exists? → Install as settings.devflow.json - settings.json missing? → Install as settings.json - CLAUDE.md exists? → Install as CLAUDE.devflow.md - CLAUDE.md missing? → Install as CLAUDE.md Final message shows clear merge instructions: - Review settings.devflow.json and merge statusLine config - Review CLAUDE.devflow.md and adopt desired practices Benefits: - Much simpler code (~80 lines removed) - Never touches user's existing files - Clear instructions for manual merge - No complex state management - No backup/restore logic needed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: address code review issues - extract utils, fix race conditions, async operations Code Quality Improvements: - Extract shared utilities to src/cli/utils/ (eliminated 65 lines of duplication) - Created paths.ts with getInstallationPaths(), path validation, env var security - Created git.ts with async getGitRoot() using promisified exec - Both init.ts and uninstall.ts now use shared utilities Security & Reliability: - Fixed TOCTOU race conditions with atomic file operations ('wx' flag) - settings.json, CLAUDE.md, .claudeignore now use exclusive create - Added environment variable path validation (CLAUDE_CODE_DIR, DEVFLOW_DIR) - Validates absolute paths, warns if outside home directory Performance: - Replaced execSync with async exec (non-blocking git operations) - Eliminated redundant git root detection (was called twice) - All file operations now async throughout the codebase CI/CD Compatibility: - Added TTY detection for interactive prompts - Falls back to default scope in non-interactive environments - Clear messaging when non-TTY detected Documentation: - Added comprehensive CHANGELOG entry for v0.5.0 - Documented all fixes, improvements, and breaking changes - Migration notes for existing users Tested: - User scope installation: ✓ - Local scope installation: ✓ - TTY detection and fallback: ✓ - Auto-detection uninstall: ✓ - Atomic file operations: ✓ - All async operations: ✓ Closes code review issues #2, #4, #5, #6 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: bump version to 0.5.0 Release 0.5.0 with installation scope support and smart uninstall detection Major Features: - Two-tier installation strategy (user-wide vs project-specific) - Interactive scope selection with clear descriptions - Smart uninstall with automatic scope detection - Environment variable path validation for security - TTY detection for CI/CD compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Dean Sharon <deanshrn@gmain.com> Co-authored-by: Claude <noreply@anthropic.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Overview
This PR implements a language-agnostic global CLAUDE.md and specialized TypeScript auditor agent to maintain DevFlow's universal design philosophy while preserving deep language-specific expertise where needed.
📦 What's Included
1. Language-Agnostic Global CLAUDE.md (
src/claude/CLAUDE.md)Problem: Previous global CLAUDE.md contained TypeScript-specific syntax, violating language-agnostic design.
Solution: Stripped TypeScript specifics, kept universal engineering concepts.
Contents:
Size: ~330 lines of precise, non-bloated instructions
2. TypeScript Auditor Agent (
src/claude/agents/devflow/audit-typescript.md)Problem: Need TypeScript-specific enforcement without polluting global config.
Solution: Specialized auditor with built-in detection logic.
Detection Strategy:
What It Audits:
anytype usage (CRITICAL violations)@ts-ignore/@ts-expect-errorabuseOutput: CRITICAL/HIGH/MEDIUM/LOW severity with
file:linereferences3. Smart CLAUDE.md Mounting (
src/cli/commands/init.ts)Problem: Need to install global CLAUDE.md without overriding users' existing configs.
Solution: Smart mounting logic parallel to settings.json pattern.
Installation Scenarios
Scenario 1: Fresh Install (No Existing CLAUDE.md)
Scenario 2: Existing CLAUDE.md (Safe Install)
Scenario 3: Force Override with Prompt
Scenario 4: Force Override with Auto-Approval
New CLI Options
--force: Override existing settings.json and CLAUDE.md (prompts for confirmation)-y, --yes: Auto-approve all prompts (use with --force)4. Pre-commit/Pre-PR Integration
Updated Commands:
src/claude/commands/devflow/pre-commit.mdsrc/claude/commands/devflow/pre-pr.mdChanges:
audit-typescriptto agent orchestrationPre-commit Audits (6 total):
Pre-PR Audits (8-9 total):
🧪 Testing
All scenarios tested locally:
✅ Scenario 1: Fresh Install
✅ Scenario 2: Existing Files
✅ Scenario 3: Force with Prompt Decline
✅ Scenario 4: Force with Auto-Approval
✅ Scenario 5: Custom Content Preservation
🎁 Benefits
Language-Agnostic Design
Specialized Expertise
Extensible Pattern
audit-python,audit-go,audit-rustSafe by Default
Automation-Friendly
--force -yfor scripts/CI/CD📊 File Changes
New Files
src/claude/CLAUDE.md(332 lines) - Language-agnostic global instructionssrc/claude/agents/devflow/audit-typescript.md(275 lines) - TypeScript auditorModified Files
src/cli/commands/init.ts(+120 lines) - Smart CLAUDE.md mountingsrc/claude/commands/devflow/pre-commit.md(+9 lines) - TS auditor integrationsrc/claude/commands/devflow/pre-pr.md(+12 lines) - TS auditor integrationTotal: 5 files changed, 801 insertions(+), 29 deletions(-)
🔄 Migration Path
For Existing Users
Option 1: Keep Existing Config
npx devflow-kit initCLAUDE.devflow.mdCLAUDE.mdOption 2: Replace with DevFlow Config
npx devflow-kit init --force -yCLAUDE.md.backupcp ~/.claude/CLAUDE.md.backup ~/.claude/CLAUDE.mdOption 3: Start Fresh
~/.claude/CLAUDE.mdnpx devflow-kit init🚀 Next Steps
Future Language-Specific Auditors
Following the same pattern:
audit-python- Python best practicesaudit-go- Go conventionsaudit-rust- Rust best practicesaudit-sql- Database best practices✅ Checklist
🤖 AI-Generated
This PR was developed with AI assistance following DevFlow's own best practices.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com