aiwg-regenerate-claude
Regenerate CLAUDE.md for Claude Code with hook file architecture
What this skill does
<!-- AIWG-SKILL-CALLOUT -->
> **Skill access pattern (post-kernel-pivot, 2026.5+)**
>
> Skill names referenced in this document's *narrative* are AIWG skills, **not slash commands**. Most are not kernel-listed and cannot be invoked as `/skill-name` by the platform. Reach them via:
>
> ```bash
> aiwg discover "<capability>"
> aiwg show skill <name>
> ```
>
> Only kernel-listed skills (`aiwg-doctor`, `aiwg-refresh`, `aiwg-status`, `aiwg-help`, `use`, `steward`) are directly invokable as slash commands. See [skill-discovery rule](../../rules/skill-discovery.md).
>
> **Exception**: The "Available Slash Commands (Claude Code)" template block below is *generated output* destined for end-user CLAUDE.md files, where Claude Code's slash-command syntax applies. Slash prefixes in that block are preserved intentionally.
# Regenerate CLAUDE.md
Regenerate the CLAUDE.md file for Claude Code integration. This command performs an **intelligent merge** — analyzing the current project state while preserving team-written content.
**Hook file architecture (default):** Generates `AIWG.md` with all AIWG context, and adds a single `@AIWG.md` directive to CLAUDE.md. This keeps CLAUDE.md minimal and user-owned.
**Full injection (`--full-inject`):** Legacy mode — injects full AIWG content directly into CLAUDE.md (useful for platforms that do not support @-link loading, or user preference).
**Vendor-specific filtering:** This command includes ONLY Claude Code slash commands and agents, reducing context pollution. Other vendor content is referenced but not inlined.
## Core Principle
**Team content is preserved. AIWG content is updated. Only Claude-specific content is inlined.**
The agent must distinguish between:
- **Team content**: Project rules, conventions, requirements, decisions written by humans
- **AIWG content**: Framework integration, agent definitions, reference links generated by AIWG
- **Claude-specific**: Slash commands, Claude agents, Claude settings
- **Other vendors**: Copilot, Cursor, Warp commands (reference only)
## Parameters
| Flag | Description |
|------|-------------|
| `--no-backup` | Skip creating backup file |
| `--dry-run` | Preview changes without writing |
| `--full` | Full regeneration - replaces everything (destructive) |
| `--full-inject` | Inject AIWG content directly into CLAUDE.md (legacy/compatibility mode) |
| `--migrate` | Migrate existing full-injection to hook file approach (runs `/migrate-hook --provider claude`) |
## Hook File Architecture (Default)
When running without `--full-inject`:
1. **Generate `AIWG.md`** — assembles AIWG context from installed framework manifests
2. **Update `CLAUDE.md`** — minimal: user content + `@AIWG.md` directive
```markdown
# CLAUDE.md
## Repository Purpose
[your project description]
@AIWG.md
## Project-Specific Notes
[your team conventions here]
```
To revert to inline injection: `/aiwg-regenerate-claude --full-inject`
To disable context temporarily: `aiwg hook-disable`
## Execution Steps
### Step 1: Create Backup
Unless `--no-backup` specified:
1. Check if `CLAUDE.md` exists
2. If exists, copy to `CLAUDE.md.backup-{YYYYMMDD-HHMMSS}`
3. Report: `Backup created: CLAUDE.md.backup-20260113-152233`
If no existing file, skip backup and note: `No existing CLAUDE.md found, generating fresh.`
### Step 2: Analyze Existing Content
If existing CLAUDE.md present (and not `--full`):
**Read the file and intelligently categorize each section:**
**Team Content (PRESERVE):**
- Project-specific coding standards and conventions
- API guidelines and architectural decisions
- Security policies and compliance requirements
- Team workflows and processes
- Business rules and constraints
- Definition of Done criteria
- Historical context and rationale
- Any content that reflects human decisions about the project
**AIWG Content (UPDATE):**
- AIWG Integration sections
- Agent definitions and listings
- Command listings
- @-mention reference tables
- Orchestration instructions
- Framework version information
- Auto-detected project info (tech stack, commands)
**Identification Heuristics:**
- Team content often uses first-person ("we", "our team")
- Team content references specific business/domain terms
- Team content contains opinions, preferences, rationale
- AIWG content references `~/.local/share/ai-writing-guide`
- AIWG content has structured @-mention tables
- AIWG content lists agents, commands, frameworks
### Step 3: Analyze Project
**Detect 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`:
```json
{
"scripts": {
"build": "tsc",
"test": "vitest",
"lint": "eslint ."
}
}
```
From `Makefile`:
```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
```
### Step 4: Detect AIWG State
**Check for installed frameworks:**
1. Read `.aiwg/frameworks/registry.json` if exists
2. Scan `.claude/agents/` for deployed agents (Claude-specific)
3. Scan `.claude/commands/` for deployed commands (Claude-specific)
4. Read `~/.local/share/ai-writing-guide/registry.json` for global state
**Identify active frameworks:**
- Count agent files matching sdlc-complete patterns
- Count command files matching sdlc-complete patterns
- Detect aiwg-utils presence
- Detect media-marketing-kit presence
**Check Claude-specific config:**
Read `.claude/settings.local.json` if exists for:
- Allowed read paths
- Allowed write paths
- Allowed bash commands
### Step 5: Generate CLAUDE.md
**Document Structure:**
```markdown
# 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}
```
## Testing
- **Framework**: {detected framework}
- **Run tests**: `{test command}`
- **Coverage**: `{coverage command if found}`
- **Location**: `{test directory}`
## Architecture
{Description based on directory structure}
### Directory Structure
```
{key directories with descriptions}
```
## Important Files
- `{file}` - {purpose}
{repeat for key files}
## Configuration
{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}
---
## Project Artifacts
{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}
{ENHANCEMENTRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.