Regenerate CLAUDE.md for Claude Code with intelligent content preservation
Regenerate CLAUDE.md with intelligent preservation of team-written content while updating AIWG integration sections. Use this when project structure changes or AIWG components are added/removed.
/plugin marketplace add jmagly/ai-writing-guide/plugin install jmagly-utils-plugins-utils@jmagly/ai-writing-guideRegenerate the CLAUDE.md file for Claude Code integration. This command performs an intelligent merge - analyzing the current project state while preserving team-written content.
Team content is preserved. AIWG content is updated.
The agent must distinguish between:
| Flag | Description |
|---|---|
--no-backup | Skip creating backup file |
--dry-run | Preview changes without writing |
--full | Full regeneration - replaces everything (destructive) |
Unless --no-backup specified:
CLAUDE.md existsCLAUDE.md.backup-{YYYYMMDD-HHMMSS}Backup created: CLAUDE.md.backup-20251206-152233If no existing file, skip backup and note: No existing CLAUDE.md found, generating fresh.
If existing CLAUDE.md present (and not --full):
Read the file and intelligently categorize each section:
Team Content (PRESERVE):
AIWG Content (UPDATE):
Identification Heuristics:
~/.local/share/ai-writing-guideDetect Languages & Package Managers:
Use Glob to find package files:
package.json → Node.js/npm
pyproject.toml / requirements.txt → Python
go.mod → Go
Cargo.toml → Rust
pom.xml / build.gradle → Java
composer.json → PHP
Gemfile → Ruby
Extract Development Commands:
From package.json:
{
"scripts": {
"build": "tsc",
"test": "vitest",
"lint": "eslint ."
}
}
From Makefile:
build:
go build ./...
test:
go test ./...
Detect Test Framework:
| File Pattern | Framework |
|---|---|
jest.config.* | Jest |
vitest.config.* | Vitest |
pytest.ini, conftest.py | Pytest |
*_test.go | Go testing |
.rspec | RSpec |
phpunit.xml | PHPUnit |
Detect CI/CD:
| Path | Platform |
|---|---|
.github/workflows/*.yml | GitHub Actions |
.gitlab-ci.yml | GitLab CI |
Jenkinsfile | Jenkins |
.circleci/config.yml | CircleCI |
azure-pipelines.yml | Azure DevOps |
Extract Project Description:
Read first meaningful paragraph from README.md or description from package.json.
Analyze Directory Structure:
src/ or lib/ → Source code
test/ or tests/ or __tests__/ → Tests
docs/ → Documentation
scripts/ or tools/ → Tooling
.github/ → GitHub configuration
Check for installed frameworks:
.aiwg/frameworks/registry.json if exists.claude/agents/ for deployed agents.claude/commands/ for deployed commands~/.local/share/ai-writing-guide/registry.json for global stateIdentify active frameworks:
Check Claude-specific config:
Read .claude/settings.local.json if exists for:
Document Structure:
# CLAUDE.md
This file provides guidance to Claude Code when working with this codebase.
## Repository Purpose
{First paragraph from README.md or package.json description}
## Tech Stack
- **Languages**: {detected languages}
- **Runtime**: {Node.js version, Python version, etc.}
- **Package Manager**: {npm, yarn, pip, etc.}
- **Framework**: {React, FastAPI, etc. if detected}
- **Database**: {if detected from dependencies}
## Development Commands
```bash
# {grouped by purpose}
{extracted commands with descriptions}
{test command}{coverage command if found}{test directory}{Description based on directory structure}
{key directories with descriptions}
{file} - {purpose}
{repeat for key files}{List of config files and their purpose}
{INSERT ALL TEAM CONTENT HERE - EXACTLY AS FOUND}
{If team content exists, preserve it verbatim in its original location/order}
{If .aiwg/ directory exists, wire up project-specific docs:}
| Category | Location |
|---|---|
| Requirements | @.aiwg/requirements/ |
| Architecture | @.aiwg/architecture/ |
| Planning | @.aiwg/planning/ |
| Testing | @.aiwg/testing/ |
| Security | @.aiwg/security/ |
{Only include rows for directories that exist}
{ENHANCEMENT: Add @-mentions below team sections to link with AIWG resources} {Example: If team has "Security Requirements" section, add below it:} {Related: @.aiwg/security/, /flow-security-review-cycle, /flow-compliance-validation}
AIWG is installed at: ~/.local/share/ai-writing-guide
| Component | Type | Count |
|---|---|---|
| {table of installed frameworks, addons - only if any installed} |
{List of deployed agents from .claude/agents/ - brief descriptions}
{List of deployed commands from .claude/commands/ - organized by category}
You are the Core Orchestrator. When users request workflows:
Use @-mentions to load guidance as needed:
| Topic | Reference |
|---|---|
| Orchestration | @~/.local/share/ai-writing-guide/agentic/code/addons/aiwg-utils/prompts/core/orchestrator.md |
| Agent Design | @~/.local/share/ai-writing-guide/agentic/code/addons/aiwg-utils/prompts/agents/design-rules.md |
| Error Recovery | @~/.local/share/ai-writing-guide/agentic/code/addons/aiwg-utils/prompts/reliability/resilience.md |
{If SDLC framework installed, add:}
| Topic | Reference |
|---|---|
| Natural Language | @~/.local/share/ai-writing-guide/agentic/code/frameworks/sdlc-complete/docs/simple-language-translations.md |
| Orchestration | @~/.local/share/ai-writing-guide/agentic/code/frameworks/sdlc-complete/docs/orchestrator-architecture.md |
{If Marketing framework installed, add similar section}
### Step 6: Write Output
**If `--dry-run`:**
Display the generated content, do not write.
**Otherwise:**
1. Write generated content to `CLAUDE.md`
2. Verify write succeeded
3. Report summary
Backup: CLAUDE.md.backup-20251206-152233
Team Content Preserved: ✓ Team Conventions (18 lines) ✓ Definition of Done (9 lines) ✓ Security Requirements (7 lines) ✓ API Guidelines (12 lines)
AIWG Content Updated: ✓ Tech Stack (TypeScript, Node.js 18+) ✓ Development Commands (12 scripts) ✓ Testing (Vitest) ✓ Project Artifacts (@-mentions) ✓ AIWG Integration - sdlc-complete (54 agents, 42 commands) - aiwg-utils (core utilities)
Enhancements Added: ✓ Linked Security Requirements → flow-security-review-cycle ✓ Linked API Guidelines → architecture docs
Output: CLAUDE.md (428 lines, 18,234 bytes)
## Content Enhancement
When preserving team content, the agent MAY add helpful @-mentions and links below team sections **without modifying the team's words**.
**Example:**
Team wrote:
```markdown
## Security Requirements
- Must comply with SOC2
- All data encrypted at rest
- Quarterly penetration testing
Agent enhances:
## Security Requirements
- Must comply with SOC2
- All data encrypted at rest
- Quarterly penetration testing
Related: /flow-security-review-cycle, /flow-compliance-validation SOC2, @.aiwg/security/
The team's content is untouched. Links are added below.
The agent MAY update genuinely outdated information:
The agent MUST NOT change:
# Regenerate CLAUDE.md with intelligent preservation
/aiwg-regenerate-claude
# Preview without writing
/aiwg-regenerate-claude --dry-run
# Full regeneration (replaces everything)
/aiwg-regenerate-claude --full
# Skip backup (use carefully)
/aiwg-regenerate-claude --no-backup
| Condition | Action |
|---|---|
| No CLAUDE.md exists | Generate fresh document |
| Backup fails | Abort, report error |
| Read error | Report error, suggest --full |
| No AIWG detected | Generate project-only content, warn |
| No package files | Generate minimal structure, warn |
| Ambiguous content | Preserve it (err on side of caution) |
/aiwg-regenerate-warp/aiwg-regenerate-factory/aiwg-regenerate