git clone https://github.com/jmagly/aiwg
T=$(mktemp -d) && git clone --depth=1 https://github.com/jmagly/aiwg "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.agents/skills/aiwg-regenerate" ~/.claude/skills/jmagly-aiwg-aiwg-regenerate && rm -rf "$T"
.agents/skills/aiwg-regenerate/SKILL.mdRegenerate Platform Context File
Analyze current project state and regenerate the platform context file (CLAUDE.md, WARP.md, or AGENTS.md) while preserving team directives and organizational requirements.
By default, uses the hook file architecture: generates
AIWG.md (or provider equivalent) and adds a single directive to the context file. Use --full-inject for the legacy inline approach.
Parameters
| Flag | Description |
|---|---|
| Skip creating backup file |
| Preview changes without writing |
| List all detected preserved content and exit |
| Full regeneration, preserve nothing (destructive) |
| Inject AIWG content directly into context file (legacy/compatibility mode) |
| Regenerate for ALL installed providers simultaneously |
| Migrate existing full-injection to hook file approach |
Platform Detection
Detect current platform automatically by checking for existing context files:
| Priority | Check | Platform | Command |
|---|---|---|---|
| 1 | exists | Claude Code | |
| 2 | exists | Warp Terminal | |
| 3 | exists | Cursor | |
| 4 | exists | Windsurf | |
| 5 | exists | GitHub Copilot | |
| 6 | exists | Codex | |
| 7 | exists | OpenCode | |
| 8 | exists + | Factory AI | |
| 9 | exists | Windsurf/generic | |
| 10 | exists | Factory AI | |
| 11 | exists | Cursor | |
| 12 | exists | Windsurf | |
| 13 | exists | GitHub Copilot | |
If multiple files exist, use priority order. If ambiguous, ask user.
--all
Mode
--allRegenerate all detected providers simultaneously:
Detected providers: claude, warp, cursor Regenerating all... ✓ CLAUDE.md → AIWG.md (312 lines) ✓ WARP.md → AIWG-warp.md (298 lines) ✓ .cursorrules → AIWG-cursor.md (295 lines) Regenerated 3 providers.
For explicit platform targeting, use:
→ CLAUDE.md + AIWG.md/aiwg-regenerate-claude
→ WARP.md + AIWG-warp.md/aiwg-regenerate-warp
→ AGENTS.md + AIWG-agents.md/aiwg-regenerate-agents
→ .cursorrules + AIWG-cursor.md/aiwg-regenerate-cursorrules
→ .windsurfrules + AIWG-windsurf.md/aiwg-regenerate-windsurfrules
→ copilot-instructions.md + AIWG-copilot.md/aiwg-regenerate-copilot
→ AGENTS.md + AIWG-factory.md/aiwg-regenerate-factory
→ .opencode/context.md + AIWG-opencode.md/aiwg-regenerate-opencode
→ CODEX.md (full inject, no @-link support)/aiwg-regenerate-codex
Execution Steps
Step 1: Detect Platform
Determine which context file to regenerate based on platform detection.
Report:
Platform detected: Claude Code Target file: CLAUDE.md
Step 2: Create Backup
Unless
--no-backup flag is set:
- Generate timestamp:
YYYYMMDD-HHMMSS - Copy current file to
{filename}.backup-{timestamp} - Report backup location
Backup created: CLAUDE.md.backup-20251206-152233
Step 3: Extract Preserved Content
Parse existing file and extract content matching preservation patterns.
Preservation Patterns:
-
Explicit Markers
<!-- PRESERVE --> Content here is always preserved <!-- /PRESERVE --> <!-- PRESERVE: Single line directive --> -
Section Headings (case-insensitive)
- Team rules/conventions## Team *
/## Org *
- Org policies## Organization *
- DoD criteria## Definition of Done
- Quality standards## Code Quality *
/## Security Requirements
- Security policies## Security Policy
- Conventions## Convention*
/## Rules
- Rules## Guidelines
/## Important *
- Important notes## Critical *
/## NFR*
- NFRs## Non-Functional *
- Standards## *Standards
- User notes## Project-Specific Notes
-
Directive Lines (within non-preserved sections)
- Lines starting with: "Do not", "Don't", "Never", "Always", "Must", "Required:", "Policy:", "Rule:"
- Lines containing:
<!-- PRESERVE:
If
flag:
Display all preserved content and exit without regenerating.--show-preserved
Preserved Content Analysis ========================== ## Sections (3 found): ### Team Conventions (lines 45-62, 18 lines) - Do not add claude code signature to commit messages - All Python commands must run within venv - Commits made without attribution ... (15 more lines) ### Definition of Done (lines 78-86, 9 lines) - All tests passing - Code reviewed - Documentation updated ... (6 more lines) ### Security Requirements (lines 92-98, 7 lines) - All API keys via environment variables - No secrets in code ... (5 more lines) ## Inline Directives (2 found): Line 34: <!-- PRESERVE: Use internal npm registry for @company/* --> Line 112: Never deploy on Fridays without approval Total: 36 lines will be preserved
Step 4: Analyze Project
Scan project to extract regenerable content:
Package Detection:
# Check for package files ls package.json pyproject.toml requirements.txt go.mod Cargo.toml pom.xml build.gradle composer.json Gemfile 2>/dev/null
Extract from package.json:
,name
,descriptionversion
→ Development commandsscripts
,dependencies
→ Tech stackdevDependencies
Extract from other sources:
→ Make targetsMakefile
→ Project description (first paragraph)README.md- Directory structure → Architecture overview
Detect Test Framework:
→ Jestjest.config.*
→ Vitestvitest.config.*
,pytest.ini
→ Pytestconftest.py
files → Go testing*_test.go
→ RSpec.rspec
Detect CI/CD:
→ GitHub Actions.github/workflows/*.yml
→ GitLab CI.gitlab-ci.yml
→ JenkinsJenkinsfile
→ CircleCI.circleci/
Report:
Project Analysis ================ Languages: TypeScript, Python Package Manager: npm Build Commands: 12 scripts detected Test Framework: Vitest CI/CD: GitHub Actions (3 workflows)
Step 5: Detect AIWG State
Check installed AIWG frameworks:
-
Check Registry
# Project registry cat .aiwg/frameworks/registry.json 2>/dev/null # Global registry cat ~/.local/share/ai-writing-guide/registry.json 2>/dev/null -
Scan Deployed Assets
# Count agents ls .claude/agents/*.md 2>/dev/null | wc -l # Count commands ls .claude/commands/*.md 2>/dev/null | wc -l -
Identify Frameworks
- Check for sdlc-complete markers
- Check for media-marketing-kit markers
- Check for addon presence
Report:
AIWG State ========== Frameworks: - sdlc-complete v1.0.0 (54 agents, 42 commands) - aiwg-utils v1.0.0 (1 agent, 4 commands)
Step 6: Generate New Document
If
flag:
Display generated content without writing.--dry-run
Structure:
# CLAUDE.md This file provides guidance to Claude Code when working with this codebase. ## Repository Purpose {Generated from README.md first paragraph or package.json description} ## Tech Stack {Generated list of detected languages, frameworks, runtimes} ## Development Commands {Generated from package.json scripts, Makefile targets, etc.} ## Testing {Generated from detected test framework} ## Architecture {Generated from directory structure analysis} ## Important Files {Key files identified during analysis} --- ## Team Directives & Standards <!-- PRESERVED SECTION - Content maintained across regeneration --> {ALL PRESERVED CONTENT INSERTED HERE} <!-- /PRESERVED SECTION --> --- ## AIWG Framework Integration {Generated from current AIWG installation state} ### Installed Frameworks {List of installed frameworks with versions} ### Available Agents {Summary of deployed agents} ### Available Commands {Summary of deployed commands} ### Orchestration {Core orchestrator role description} --- <!-- USER NOTES Add team directives, conventions, or project-specific notes below. Content in this file's preserved sections is maintained during regeneration. Use <!-- PRESERVE --> markers for content that must be kept. -->
Step 7: Write File
- Write generated content to target file
- Report summary
Regeneration Complete ===================== Backup: CLAUDE.md.backup-20251206-152233 Preserved (36 lines): - Team Conventions (18 lines) - Definition of Done (9 lines) - Security Requirements (7 lines) - Inline directives (2) Regenerated: - Repository Purpose - Tech Stack (TypeScript, Python) - Development Commands (12 scripts) - Testing (Vitest) - Architecture - AIWG Integration (sdlc-complete, aiwg-utils) Output: CLAUDE.md (428 lines)
Examples
# Standard regeneration with backup and preservation /aiwg-regenerate # Preview what would be generated /aiwg-regenerate --dry-run # See what content would be preserved /aiwg-regenerate --show-preserved # Full regeneration (loses all user content) /aiwg-regenerate --full # Regenerate without backup (use with caution) /aiwg-regenerate --no-backup
Warning for --full Flag
If
--full flag is used, display warning:
WARNING: Full regeneration will discard ALL existing content. The following will be LOST: - Team Conventions (18 lines) - Definition of Done (9 lines) - Security Requirements (7 lines) - 2 inline directives This cannot be undone (backup will still be created). Continue with full regeneration? [y/N]
Interactive Mode
When
--interactive is specified, ask strategic questions before regenerating:
- Which provider to regenerate (if multiple detected)
- Whether to use hook file or full-inject approach
- Whether to preserve all detected team directives
- Whether to create a backup
Native UX tool preference: For each question, use the platform's native interaction tool if available (e.g.,
AskUserQuestion in Claude Code). This provides a proper input UI rather than plain text output. If no native tool is available, fall back to formatted markdown with clear options. Ask one question per interaction turn.
See
@$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/native-ux-tools.md for the full pattern.
Error Handling
| Condition | Action |
|---|---|
| No existing file | Generate fresh document with empty preserved section |
| File read error | Report error, abort |
| Backup write fails | Abort with error (never overwrite without backup) |
| AIWG not detected | Generate project-only content, warn user |
| Parse error | Warn, offer as recovery option |
References
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/README.md — aiwg-utils addon overview
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/native-ux-tools.md — Platform detection and native UX tool usage
- @$AIWG_ROOT/agentic/code/addons/aiwg-utils/rules/human-authorization.md — Confirmation before destructive --full regeneration
- @$AIWG_ROOT/docs/cli-reference.md — CLI reference for aiwg sync command
- @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/README.md — SDLC framework context included in regenerated files