aiwg-regenerate
Regenerate platform context file with preserved team directives
What this skill does
> **Deterministic execution (#1266)**: this skill has a `script:` entrypoint
> that shells out to `aiwg regenerate "$@"`. Prefer
> `aiwg run skill aiwg-regenerate -- <flags>` over agent-mediated invocation.
> When invoked as a slash command on platforms without a deployed command stub,
> the agent MUST run only `aiwg regenerate <flags>` and report its output — no
> exploratory permission requests, no multi-step planning. The deterministic
> CLI is the source of truth.
# Regenerate 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 |
|------|-------------|
| `--no-backup` | Skip creating backup file |
| `--dry-run` | Preview changes without writing |
| `--show-preserved` | List all detected preserved content and exit |
| `--full` | Full regeneration, preserve nothing (destructive) |
| `--full-inject` | Inject AIWG content directly into context file (legacy/compatibility mode) |
| `--all` | Regenerate for ALL installed providers simultaneously |
| `--migrate` | Migrate existing full-injection to hook file approach |
## Platform Detection
The CLI is the source of truth for provider selection. It resolves the target in this order:
1. Explicit `--provider <name>` flag.
2. Explicit provider environment, such as `AIWG_PROVIDER` or `CLAUDECODE_PROVIDER`.
3. Active runtime environment markers, such as `CODEX_HOME` / `CODEX_SANDBOX`, Cursor, Warp, Copilot, OpenCode, Factory, Windsurf, OpenClaw, or Claude Code markers. Runtime markers win over unrelated API keys.
4. Project configuration from `.aiwg/aiwg.config` when no active runtime is detected.
5. `generic` when no provider can be inferred.
Existing context files such as `CLAUDE.md` or `AGENTS.md` are not sufficient to override the active runtime. In mixed-provider workspaces, pass `--provider <name>` when you want a provider other than the current runtime.
### `--all` Mode
Regenerate 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:
- `/aiwg-regenerate-claude` → CLAUDE.md + AIWG.md
- `/aiwg-regenerate-warp` → WARP.md + AIWG-warp.md
- `/aiwg-regenerate-agents` → AGENTS.md + AIWG-agents.md
- `/aiwg-regenerate-cursorrules` → .cursorrules + AIWG-cursor.md
- `/aiwg-regenerate-windsurfrules` → .windsurfrules + AIWG-windsurf.md
- `/aiwg-regenerate-copilot` → copilot-instructions.md + AIWG-copilot.md
- `/aiwg-regenerate-factory` → AGENTS.md + AIWG-factory.md
- `/aiwg-regenerate-opencode` → .opencode/context.md + AIWG-opencode.md
- `/aiwg-regenerate-codex` → CODEX.md (full inject, no @-link support)
## 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:
1. Generate timestamp: `YYYYMMDD-HHMMSS`
2. Copy current file to `{filename}.backup-{timestamp}`
3. 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:**
1. **Explicit Markers**
```markdown
<!-- PRESERVE -->
Content here is always preserved
<!-- /PRESERVE -->
<!-- PRESERVE: Single line directive -->
```
2. **Section Headings** (case-insensitive)
- `## Team *` - Team rules/conventions
- `## Org *` / `## Organization *` - Org policies
- `## Definition of Done` - DoD criteria
- `## Code Quality *` - Quality standards
- `## Security Requirements` / `## Security Policy` - Security policies
- `## Convention*` - Conventions
- `## Rules` / `## Guidelines` - Rules
- `## Important *` / `## Critical *` - Important notes
- `## NFR*` / `## Non-Functional *` - NFRs
- `## *Standards` - Standards
- `## Project-Specific Notes` - User notes
3. **Directive Lines** (within non-preserved sections)
- Lines starting with: "Do not", "Don't", "Never", "Always", "Must", "Required:", "Policy:", "Rule:"
- Lines containing: `<!-- PRESERVE:`
**If `--show-preserved` flag:**
Display all preserved content and exit without regenerating.
```
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:**
```bash
# 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`, `description`, `version`
- `scripts` → Development commands
- `dependencies`, `devDependencies` → Tech stack
**Extract from other sources:**
- `Makefile` → Make targets
- `README.md` → Project description (first paragraph)
- Directory structure → Architecture overview
**Detect Test Framework:**
- `jest.config.*` → Jest
- `vitest.config.*` → Vitest
- `pytest.ini`, `conftest.py` → Pytest
- `*_test.go` files → Go testing
- `.rspec` → RSpec
**Detect CI/CD:**
- `.github/workflows/*.yml` → GitHub Actions
- `.gitlab-ci.yml` → GitLab CI
- `Jenkinsfile` → Jenkins
- `.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:
1. **Check Registry**
```bash
# Project registry
cat .aiwg/frameworks/registry.json 2>/dev/null
# Global registry
cat ~/.local/share/ai-writing-guide/registry.json 2>/dev/null
```
2. **Scan Deployed Assets**
```bash
# Count agents
ls .claude/agents/*.md 2>/dev/null | wc -l
# Count commands
ls .claude/commands/*.md 2>/dev/null | wc -l
```
3. **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 `--dry-run` flag:**
Display generated content without writing.
**Structure:**
```markdown
# 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 SERelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.