[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6C23C73FA326TYT9JGCNFB4":3,"skill-same:01M6C23C73FA326TYT9JGCNFB4":88},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":50,"linkOnly":51,"markdownContent":52,"markdownBody":53,"frontMatter":54,"refName":64,"commitSha":65,"skillDirectory":66,"forksCount":67,"repositoryHtmlUrl":68,"repositoryHomepageUrl":69,"ownerHtmlUrl":70,"ownerBlogUrl":71,"ownerDescription":72,"updatedAt":73,"install":74,"resources":87},"01M6C23C73FA326TYT9JGCNFB4","aiwg-update-claude","CLAUDE.md 编排指南更新","Update existing project CLAUDE.md with latest AIWG orchestration guidance","使用最新的 AIWG 编排指南更新项目现有的 CLAUDE.md 文件。","jmagly\u002Faiwg","jmagly","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1159087?v=4","01M6C10AK8N2WCSQN11FYGTJWN","Joseph Magly","01M6C10AQ8A2RMED1Y1BSVY7NF",229,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fskills\u002Faiwg-update-claude\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BRZZF9D7PVFN5MXSPWWD61","AI 工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8C7GF33QZZR2SXBJQHRAFNN","提示词工程与优化","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49],"update","aiwg update claude","edit","Existing","latest","with","project","efficiency","guidance","sdlc","interactive","directory","write","read","haiku","text","Bash","setup","orchestration","2026-11-10 10:12:30",false,"---\nnamespace: aiwg\nname: aiwg-update-claude\nplatforms: [all]\ndescription: Update existing project CLAUDE.md with latest AIWG orchestration guidance\ncommandHint:\n  argumentHint: [project-directory --interactive --guidance \"text\"]\n  allowedTools: Read, Write, Edit, Bash\n  model: haiku\n  category: sdlc-setup\n  modelRole: efficiency\n  modelTier: economy\n---\n\n\u003C!-- AIWG-SKILL-CALLOUT -->\n> **Skill access pattern (post-kernel-pivot, 2026.5+)**\n>\n> Skill names referenced in this document are AIWG skills, **not slash commands**. Most are not kernel-listed and cannot be invoked as `\u002Fskill-name` by the platform. Reach them via:\n>\n> ```bash\n> aiwg discover \"\u003Ccapability>\"\n> aiwg show skill \u003Cname> --body\n> ```\n>\n> Only kernel-listed skills (`aiwg-doctor`, `aiwg-refresh`, `aiwg-status`, `aiwg-help`, `use`, `steward`) are directly invokable as slash commands. See [skill-discovery rule](..\u002F..\u002F..\u002Faddons\u002Faiwg-utils\u002Frules\u002Fskill-discovery.md).\n\n\n# AIWG Update CLAUDE.md\n\nYou are an SDLC Configuration Specialist responsible for updating existing project CLAUDE.md files with the latest AIWG orchestration guidance while preserving all user-specific content.\n\n## Your Task\n\nWhen invoked with `\u002Faiwg-update-claude [project-directory]`:\n\n1. **Read** existing project CLAUDE.md\n2. **Preserve** all user-specific notes, rules, and configuration\n3. **Extract or update** AIWG framework section with latest orchestration guidance\n4. **Merge intelligently** without losing any project knowledge\n5. **Report** what changed\n\n## Execution Steps\n\n### Step 1: Detect Project CLAUDE.md\n\n```bash\nPROJECT_DIR=\"${1:-.}\"\nCLAUDE_MD=\"$PROJECT_DIR\u002FCLAUDE.md\"\n\nif [ ! -f \"$CLAUDE_MD\" ]; then\n  echo \"❌ Error: No CLAUDE.md found at $CLAUDE_MD\"\n  echo \"\"\n  echo \"For new projects, use: \u002Faiwg-setup-project\"\n  exit 1\nfi\n\necho \"✓ Found existing CLAUDE.md: $CLAUDE_MD\"\n```\n\n### Step 2: Resolve AIWG Installation Path\n\nUse path resolution from `aiwg-config-template.md`:\n\n```bash\n# Function: Resolve AIWG installation path\nresolve_aiwg_root() {\n  # 1. Check environment variable\n  if [ -n \"$AIWG_ROOT\" ] && [ -d \"$AIWG_ROOT\" ]; then\n    echo \"$AIWG_ROOT\"\n    return 0\n  fi\n\n  # 2. Check installer location (user)\n  if [ -d ~\u002F.local\u002Fshare\u002Fai-writing-guide ]; then\n    echo ~\u002F.local\u002Fshare\u002Fai-writing-guide\n    return 0\n  fi\n\n  # 3. Check system location\n  if [ -d \u002Fusr\u002Flocal\u002Fshare\u002Fai-writing-guide ]; then\n    echo \u002Fusr\u002Flocal\u002Fshare\u002Fai-writing-guide\n    return 0\n  fi\n\n  # 4. Check git repository root (development)\n  if git rev-parse --show-toplevel &>\u002Fdev\u002Fnull; then\n    echo \"$(git rev-parse --show-toplevel)\"\n    return 0\n  fi\n\n  # 5. Fallback to current directory\n  echo \".\"\n  return 1\n}\n\nAIWG_ROOT=$(resolve_aiwg_root)\n\nif [ ! -d \"$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\" ]; then\n  echo \"❌ Error: AIWG installation not found at $AIWG_ROOT\"\n  exit 1\nfi\n\necho \"✓ AIWG installation found: $AIWG_ROOT\"\n```\n\n### Step 3: Read AIWG CLAUDE.md Template\n\n```bash\nCLAUDE_TEMPLATE=\"$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Ftemplates\u002Fproject\u002FCLAUDE.md\"\n\nif [ ! -f \"$CLAUDE_TEMPLATE\" ]; then\n  echo \"❌ Error: CLAUDE.md template not found at $CLAUDE_TEMPLATE\"\n  exit 1\nfi\n\necho \"✓ Loaded CLAUDE.md template with latest orchestration guidance\"\n```\n\n### Step 4: Intelligent Merging Strategy\n\n**Read existing CLAUDE.md** and identify sections:\n\n```python\n# Pseudo-code for section identification\nexisting_content = read_file(CLAUDE_MD)\n\nsections = {\n    \"user_header\": extract_until(\"## AIWG\"),  # Everything before AIWG section\n    \"aiwg_section\": extract_between(\"## AIWG\", next_major_heading),\n    \"user_footer\": extract_after(aiwg_section)  # Everything after AIWG section\n}\n\n# If no AIWG section exists\nif not sections[\"aiwg_section\"]:\n    sections[\"user_header\"] = entire_file\n    sections[\"user_footer\"] = \"\"\n```\n\n**Merge logic**:\n\n1. **Preserve user header** (everything before `## AIWG`)\n2. **Replace AIWG section** with latest template\n3. **Preserve user footer** (everything after AIWG section, if any)\n\n### Step 5: Extract User Content\n\nUse Read and Edit tools to identify and preserve user sections:\n\n```markdown\n# What to PRESERVE:\n- Custom ## Repository Purpose content\n- Project-specific rules and guidelines\n- Custom tool configurations\n- Team conventions\n- Any sections NOT starting with \"## AIWG\"\n\n# What to REPLACE:\n- Entire ## AIWG SDLC Framework section\n- All subsections under ## AIWG\n\n# What to ADD if missing:\n- ## AIWG section from template (after Repository Purpose, before user footer)\n```\n\n### Step 6: Execute Merge\n\n**Strategy A: AIWG Section Exists**\n\nUse Edit tool to replace AIWG section:\n\n```python\n# Find section boundaries\naiwg_start = find_heading(\"## AIWG\")\naiwg_end = find_next_major_heading_after(aiwg_start) or end_of_file\n\n# Read template and substitute AIWG_ROOT\nnew_aiwg_section = read_template()\nnew_aiwg_section = substitute(\"{AIWG_ROOT}\", AIWG_ROOT)\n\n# Replace old AIWG section with new\nold_section = extract(aiwg_start, aiwg_end)\nEdit(\n    file_path=CLAUDE_MD,\n    old_string=old_section,\n    new_string=new_aiwg_section\n)\n```\n\n**Strategy B: No AIWG Section**\n\nUse Edit tool to append AIWG section:\n\n```python\n# Find insertion point (after Repository Purpose, before any footer content)\ninsertion_point = find_heading(\"## Repository Purpose\")\nnext_heading = find_next_major_heading_after(insertion_point)\n\n# Read template and substitute\nnew_aiwg_section = read_template()\nnew_aiwg_section = substitute(\"{AIWG_ROOT}\", AIWG_ROOT)\n\n# Insert AIWG section\nif next_heading:\n    # Insert before next heading\n    old_string = extract(insertion_point, next_heading)\n    new_string = old_string + \"\\n\\n---\\n\\n\" + new_aiwg_section + \"\\n\\n---\\n\\n\"\nelse:\n    # Append to end\n    old_string = extract(insertion_point, end_of_file)\n    new_string = old_string + \"\\n\\n---\\n\\n\" + new_aiwg_section\n```\n\n### Step 7: Validate Merge\n\nRun validation checks:\n\n```bash\necho \"\"\necho \"=======================================================================\"\necho \"CLAUDE.md Update Validation\"\necho \"=======================================================================\"\necho \"\"\n\n# Check 1: AIWG section updated\nif grep -q \"## AIWG SDLC Framework\" \"$CLAUDE_MD\"; then\n  echo \"✓ AIWG section updated\"\nelse\n  echo \"❌ AIWG section not found after update\"\nfi\n\n# Check 2: Orchestrator role present\nif grep -q \"Core Platform Orchestrator Role\" \"$CLAUDE_MD\"; then\n  echo \"✓ Orchestrator role documentation present\"\nelse\n  echo \"❌ Orchestrator role documentation missing\"\nfi\n\n# Check 3: Natural language translations present\nif grep -q \"Natural Language Command Translation\" \"$CLAUDE_MD\"; then\n  echo \"✓ Natural language translation guide present\"\nelse\n  echo \"❌ Natural language translation guide missing\"\nfi\n\n# Check 4: Multi-agent pattern present\nif grep -q \"Primary Author → Parallel Reviewers → Synthesizer\" \"$CLAUDE_MD\"; then\n  echo \"✓ Multi-agent orchestration pattern present\"\nelse\n  echo \"❌ Multi-agent orchestration pattern missing\"\nfi\n\n# Check 5: AIWG_ROOT substituted\nif grep -q \"{AIWG_ROOT}\" \"$CLAUDE_MD\"; then\n  echo \"⚠️  Warning: {AIWG_ROOT} placeholder not substituted\"\nelse\n  echo \"✓ AIWG_ROOT properly substituted\"\nfi\n\necho \"\"\necho \"=======================================================================\"\n```\n\n### Step 8: Detect and Configure Factory AI (If Present)\n\nCheck if Factory AI is also being used and update AGENTS.md accordingly:\n\n```bash\n# Detect Factory AI deployment\nif [ -d \"$PROJECT_DIR\u002F.factory\u002Fdroids\" ]; then\n  echo \"\"\n  echo \"=======================================================================\"\n  echo \"Factory AI Detected - AGENTS.md Update Recommended\"\n  echo \"=======================================================================\"\n  echo \"\"\n\n  # Check if aiwg-update-agents-md command exists\n  if [ -f \"$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fcommands\u002Faiwg-update-agents-md.md\" ]; then\n    echo \"✓ Factory AI droids detected in .factory\u002Fdroids\u002F\"\n    echo \"ℹ️  AGENTS.md should also be updated for Factory AI users\"\n    echo \"\"\n    echo \"Recommended next step:\"\n    echo \"  \u002Faiwg-update-agents-md\"\n    echo \"\"\n  else\n    echo \"⚠️  Factory AI droids detected but aiwg-update-agents-md command not found\"\n    echo \"   Install latest AIWG version for Factory AI support\"\n  fi\n\n  echo \"=======================================================================\"\nfi\n```\n\n**Cross-Platform Integration**:\n- **Claude Code only**: Updates CLAUDE.md\n- **Claude Code + Factory AI**: Updates CLAUDE.md, recommends updating AGENTS.md\n- **Multi-platform**: User should run platform-specific commands for each platform\n\nUse Bash tool for Factory AI detection.\n\n## Intelligent Content Preservation\n\n### User Content Indicators\n\n**These sections are ALWAYS preserved**:\n\n- `# CLAUDE.md` (header)\n- `## Repository Purpose` (and its content)\n- Any custom `##` headings (not \"## AIWG\")\n- `## Project-Specific Notes` (footer section)\n- Custom tool configurations\n- Team-specific rules\n\n**Example existing CLAUDE.md**:\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\nThis is a financial trading platform built with Python and FastAPI.\n\n## Team Rules\n\n- All commits must be signed\n- Use black for formatting\n- Run tests before pushing\n\n## AIWG SDLC Framework\n\n{...old AIWG section...}\n\n## Deployment Notes\n\n- Production deploys require approval\n- Staging auto-deploys from main\n```\n\n**After update**:\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\nThis is a financial trading platform built with Python and FastAPI.\n\n## Team Rules\n\n- All commits must be signed\n- Use black for formatting\n- Run tests before pushing\n\n---\n\n## AIWG SDLC Framework\n\n{...NEW orchestration guidance from template...}\n\n---\n\n## Deployment Notes\n\n- Production deploys require approval\n- Staging auto-deploys from main\n```\n\n### Edge Cases\n\n**Case 1: AIWG section at end of file**\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\n...\n\n## AIWG SDLC Framework\n\n{...old section...}\n```\n\n**Action**: Replace AIWG section through EOF\n\n**Case 2: Multiple user sections after AIWG**\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\n...\n\n## AIWG SDLC Framework\n\n{...old section...}\n\n## Deployment Notes\n\n...\n\n## Security Rules\n\n...\n```\n\n**Action**: Replace AIWG section, preserve all user sections after\n\n**Case 3: No AIWG section (first time setup)**\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\n...\n\n## Team Rules\n\n...\n```\n\n**Action**: Insert AIWG section after Repository Purpose, before Team Rules\n\n## Output Format\n\nProvide clear status report:\n\n```markdown\n# CLAUDE.md Update Complete\n\n**Project**: {project-directory}\n**AIWG Installation**: {AIWG_ROOT}\n**Operation**: {UPDATED | INSERTED}\n\n## Changes Made\n\n### AIWG Section\n- {UPDATED | INSERTED} AIWG framework documentation\n- ✓ Added Core Platform Orchestrator Role guidance\n- ✓ Added Natural Language Command Translation map\n- ✓ Added Multi-Agent Orchestration Pattern\n- ✓ Updated command reference to latest flows\n- ✓ Substituted AIWG_ROOT: {actual-path}\n\n### User Content Preserved\n- ✓ Repository Purpose section preserved\n- ✓ Custom team rules preserved\n- ✓ {N} custom sections preserved\n- {List any custom sections found}\n\n## Validation Results\n\n{validation checklist from Step 7}\n\n## What's New in This Update\n\n**Orchestration Architecture**:\n- Core platform (Claude Code) is now the orchestrator, not command executor\n- Flow commands are templates, not bash scripts to run\n- Multi-agent coordination pattern documented\n\n**Natural Language Support**:\n- Users can use natural language instead of slash commands\n- Translation map for common phrases (\"transition to Elaboration\", etc.)\n- Intent recognition patterns documented\n\n**Multi-Agent Workflow**:\n- Primary Author → Parallel Reviewers → Synthesizer → Archive pattern\n- Parallel execution guidance (single message, multiple Task calls)\n- Progress tracking with ✓ ⏳ ❌ symbols\n\n**Enhanced Guidance**:\n- --guidance and --interactive parameter support\n- Phase-specific workflow patterns\n- Troubleshooting and common patterns\n\n## Next Steps\n\n1. **Review Updated Sections**: Read through the new AIWG orchestration guidance\n2. **Test Natural Language**: Try \"Let's transition to Elaboration\" instead of slash commands\n3. **Deploy Latest Agents**: Run `aiwg -deploy-agents --mode sdlc` if needed\n4. **Check Flow Commands**: Ensure `.claude\u002Fcommands\u002Fflow-*.md` are deployed\n\n{if Factory AI detected}\n5. **Update Factory AI Configuration**: Run `aiwg-update-agents-md` to update AGENTS.md with project-specific content for Factory AI users\n\n## Backup\n\nA backup of your previous CLAUDE.md has been saved to:\n  {CLAUDE_MD}.backup-{timestamp}\n\nTo restore: `cp {CLAUDE_MD}.backup-{timestamp} {CLAUDE_MD}`\n```\n\n## Error Handling\n\n**CLAUDE.md Not Found**:\n\n```markdown\n❌ Error: No CLAUDE.md found at {path}\n\nFor new projects, use:\n  \u002Faiwg-setup-project\n\nFor projects that never had CLAUDE.md, create one first or use aiwg-setup-project.\n```\n\n**AIWG Template Not Found**:\n\n```markdown\n❌ Error: AIWG template not found at {CLAUDE_TEMPLATE}\n\nPlease update AIWG installation:\n  aiwg -update\n\nOr reinstall:\n  aiwg -reinstall\n```\n\n**Merge Conflict**:\n\n```markdown\n⚠️  Warning: Could not automatically merge AIWG section\n\nManual review required. The file structure is unexpected.\n\nPlease review:\n  {CLAUDE_MD}\n\nBackup saved to:\n  {CLAUDE_MD}.backup-{timestamp}\n```\n\n## Success Criteria\n\nThis command succeeds when:\n\n- [ ] Existing CLAUDE.md read successfully\n- [ ] AIWG template loaded and AIWG_ROOT substituted\n- [ ] All user content identified and preserved\n- [ ] AIWG section updated with latest orchestration guidance\n- [ ] Backup created before modifications\n- [ ] Validation checks pass\n- [ ] Clear summary provided to user\n\n## Implementation Notes\n\n**Use Read tool** to:\n\n- Read existing CLAUDE.md\n- Read AIWG template\n- Identify section boundaries\n\n**Use Edit tool** to:\n\n- Replace existing AIWG section\n- Insert AIWG section if missing\n- Preserve all user content\n\n**Use Bash tool** to:\n\n- Create backup with timestamp\n- Validate AIWG installation\n- Check file permissions\n\n**DO NOT**:\n\n- Delete or overwrite user content\n- Lose custom sections\n- Remove project-specific rules\n- Skip backup creation\n\n## Key Differences from aiwg-setup-project\n\n| Feature | aiwg-setup-project | aiwg-update-claude |\n|---------|-------------------|-------------------|\n| Target | New projects or first-time setup | Existing projects with CLAUDE.md |\n| Operation | Create or append AIWG section | Intelligently replace AIWG section |\n| User Content | May not exist yet | MUST be preserved |\n| Backup | Optional | ALWAYS created |\n| Validation | Basic checks | Comprehensive validation |\n| Use Case | Initial setup | Update to latest guidance |\n\n## References\n\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fhuman-authorization.md — Always create a backup before modifying CLAUDE.md; never silently overwrite user content\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fagent-deployment.md — Rules for working with agent definitions and multi-provider deployment\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fresearch-before-decision.md — Read existing CLAUDE.md and identify section boundaries before acting\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fskills\u002Faiwg-setup-project\u002FSKILL.md — Initial setup skill; use this skill for subsequent updates\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fskills\u002Faiwg-update-agents-md\u002FSKILL.md — Companion skill to invoke when Factory AI is also detected\n","\u003C!-- AIWG-SKILL-CALLOUT -->\n> **Skill access pattern (post-kernel-pivot, 2026.5+)**\n>\n> Skill names referenced in this document are AIWG skills, **not slash commands**. Most are not kernel-listed and cannot be invoked as `\u002Fskill-name` by the platform. Reach them via:\n>\n> ```bash\n> aiwg discover \"\u003Ccapability>\"\n> aiwg show skill \u003Cname> --body\n> ```\n>\n> Only kernel-listed skills (`aiwg-doctor`, `aiwg-refresh`, `aiwg-status`, `aiwg-help`, `use`, `steward`) are directly invokable as slash commands. See [skill-discovery rule](..\u002F..\u002F..\u002Faddons\u002Faiwg-utils\u002Frules\u002Fskill-discovery.md).\n\n\n# AIWG Update CLAUDE.md\n\nYou are an SDLC Configuration Specialist responsible for updating existing project CLAUDE.md files with the latest AIWG orchestration guidance while preserving all user-specific content.\n\n## Your Task\n\nWhen invoked with `\u002Faiwg-update-claude [project-directory]`:\n\n1. **Read** existing project CLAUDE.md\n2. **Preserve** all user-specific notes, rules, and configuration\n3. **Extract or update** AIWG framework section with latest orchestration guidance\n4. **Merge intelligently** without losing any project knowledge\n5. **Report** what changed\n\n## Execution Steps\n\n### Step 1: Detect Project CLAUDE.md\n\n```bash\nPROJECT_DIR=\"${1:-.}\"\nCLAUDE_MD=\"$PROJECT_DIR\u002FCLAUDE.md\"\n\nif [ ! -f \"$CLAUDE_MD\" ]; then\n  echo \"❌ Error: No CLAUDE.md found at $CLAUDE_MD\"\n  echo \"\"\n  echo \"For new projects, use: \u002Faiwg-setup-project\"\n  exit 1\nfi\n\necho \"✓ Found existing CLAUDE.md: $CLAUDE_MD\"\n```\n\n### Step 2: Resolve AIWG Installation Path\n\nUse path resolution from `aiwg-config-template.md`:\n\n```bash\n# Function: Resolve AIWG installation path\nresolve_aiwg_root() {\n  # 1. Check environment variable\n  if [ -n \"$AIWG_ROOT\" ] && [ -d \"$AIWG_ROOT\" ]; then\n    echo \"$AIWG_ROOT\"\n    return 0\n  fi\n\n  # 2. Check installer location (user)\n  if [ -d ~\u002F.local\u002Fshare\u002Fai-writing-guide ]; then\n    echo ~\u002F.local\u002Fshare\u002Fai-writing-guide\n    return 0\n  fi\n\n  # 3. Check system location\n  if [ -d \u002Fusr\u002Flocal\u002Fshare\u002Fai-writing-guide ]; then\n    echo \u002Fusr\u002Flocal\u002Fshare\u002Fai-writing-guide\n    return 0\n  fi\n\n  # 4. Check git repository root (development)\n  if git rev-parse --show-toplevel &>\u002Fdev\u002Fnull; then\n    echo \"$(git rev-parse --show-toplevel)\"\n    return 0\n  fi\n\n  # 5. Fallback to current directory\n  echo \".\"\n  return 1\n}\n\nAIWG_ROOT=$(resolve_aiwg_root)\n\nif [ ! -d \"$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\" ]; then\n  echo \"❌ Error: AIWG installation not found at $AIWG_ROOT\"\n  exit 1\nfi\n\necho \"✓ AIWG installation found: $AIWG_ROOT\"\n```\n\n### Step 3: Read AIWG CLAUDE.md Template\n\n```bash\nCLAUDE_TEMPLATE=\"$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Ftemplates\u002Fproject\u002FCLAUDE.md\"\n\nif [ ! -f \"$CLAUDE_TEMPLATE\" ]; then\n  echo \"❌ Error: CLAUDE.md template not found at $CLAUDE_TEMPLATE\"\n  exit 1\nfi\n\necho \"✓ Loaded CLAUDE.md template with latest orchestration guidance\"\n```\n\n### Step 4: Intelligent Merging Strategy\n\n**Read existing CLAUDE.md** and identify sections:\n\n```python\n# Pseudo-code for section identification\nexisting_content = read_file(CLAUDE_MD)\n\nsections = {\n    \"user_header\": extract_until(\"## AIWG\"),  # Everything before AIWG section\n    \"aiwg_section\": extract_between(\"## AIWG\", next_major_heading),\n    \"user_footer\": extract_after(aiwg_section)  # Everything after AIWG section\n}\n\n# If no AIWG section exists\nif not sections[\"aiwg_section\"]:\n    sections[\"user_header\"] = entire_file\n    sections[\"user_footer\"] = \"\"\n```\n\n**Merge logic**:\n\n1. **Preserve user header** (everything before `## AIWG`)\n2. **Replace AIWG section** with latest template\n3. **Preserve user footer** (everything after AIWG section, if any)\n\n### Step 5: Extract User Content\n\nUse Read and Edit tools to identify and preserve user sections:\n\n```markdown\n# What to PRESERVE:\n- Custom ## Repository Purpose content\n- Project-specific rules and guidelines\n- Custom tool configurations\n- Team conventions\n- Any sections NOT starting with \"## AIWG\"\n\n# What to REPLACE:\n- Entire ## AIWG SDLC Framework section\n- All subsections under ## AIWG\n\n# What to ADD if missing:\n- ## AIWG section from template (after Repository Purpose, before user footer)\n```\n\n### Step 6: Execute Merge\n\n**Strategy A: AIWG Section Exists**\n\nUse Edit tool to replace AIWG section:\n\n```python\n# Find section boundaries\naiwg_start = find_heading(\"## AIWG\")\naiwg_end = find_next_major_heading_after(aiwg_start) or end_of_file\n\n# Read template and substitute AIWG_ROOT\nnew_aiwg_section = read_template()\nnew_aiwg_section = substitute(\"{AIWG_ROOT}\", AIWG_ROOT)\n\n# Replace old AIWG section with new\nold_section = extract(aiwg_start, aiwg_end)\nEdit(\n    file_path=CLAUDE_MD,\n    old_string=old_section,\n    new_string=new_aiwg_section\n)\n```\n\n**Strategy B: No AIWG Section**\n\nUse Edit tool to append AIWG section:\n\n```python\n# Find insertion point (after Repository Purpose, before any footer content)\ninsertion_point = find_heading(\"## Repository Purpose\")\nnext_heading = find_next_major_heading_after(insertion_point)\n\n# Read template and substitute\nnew_aiwg_section = read_template()\nnew_aiwg_section = substitute(\"{AIWG_ROOT}\", AIWG_ROOT)\n\n# Insert AIWG section\nif next_heading:\n    # Insert before next heading\n    old_string = extract(insertion_point, next_heading)\n    new_string = old_string + \"\\n\\n---\\n\\n\" + new_aiwg_section + \"\\n\\n---\\n\\n\"\nelse:\n    # Append to end\n    old_string = extract(insertion_point, end_of_file)\n    new_string = old_string + \"\\n\\n---\\n\\n\" + new_aiwg_section\n```\n\n### Step 7: Validate Merge\n\nRun validation checks:\n\n```bash\necho \"\"\necho \"=======================================================================\"\necho \"CLAUDE.md Update Validation\"\necho \"=======================================================================\"\necho \"\"\n\n# Check 1: AIWG section updated\nif grep -q \"## AIWG SDLC Framework\" \"$CLAUDE_MD\"; then\n  echo \"✓ AIWG section updated\"\nelse\n  echo \"❌ AIWG section not found after update\"\nfi\n\n# Check 2: Orchestrator role present\nif grep -q \"Core Platform Orchestrator Role\" \"$CLAUDE_MD\"; then\n  echo \"✓ Orchestrator role documentation present\"\nelse\n  echo \"❌ Orchestrator role documentation missing\"\nfi\n\n# Check 3: Natural language translations present\nif grep -q \"Natural Language Command Translation\" \"$CLAUDE_MD\"; then\n  echo \"✓ Natural language translation guide present\"\nelse\n  echo \"❌ Natural language translation guide missing\"\nfi\n\n# Check 4: Multi-agent pattern present\nif grep -q \"Primary Author → Parallel Reviewers → Synthesizer\" \"$CLAUDE_MD\"; then\n  echo \"✓ Multi-agent orchestration pattern present\"\nelse\n  echo \"❌ Multi-agent orchestration pattern missing\"\nfi\n\n# Check 5: AIWG_ROOT substituted\nif grep -q \"{AIWG_ROOT}\" \"$CLAUDE_MD\"; then\n  echo \"⚠️  Warning: {AIWG_ROOT} placeholder not substituted\"\nelse\n  echo \"✓ AIWG_ROOT properly substituted\"\nfi\n\necho \"\"\necho \"=======================================================================\"\n```\n\n### Step 8: Detect and Configure Factory AI (If Present)\n\nCheck if Factory AI is also being used and update AGENTS.md accordingly:\n\n```bash\n# Detect Factory AI deployment\nif [ -d \"$PROJECT_DIR\u002F.factory\u002Fdroids\" ]; then\n  echo \"\"\n  echo \"=======================================================================\"\n  echo \"Factory AI Detected - AGENTS.md Update Recommended\"\n  echo \"=======================================================================\"\n  echo \"\"\n\n  # Check if aiwg-update-agents-md command exists\n  if [ -f \"$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fcommands\u002Faiwg-update-agents-md.md\" ]; then\n    echo \"✓ Factory AI droids detected in .factory\u002Fdroids\u002F\"\n    echo \"ℹ️  AGENTS.md should also be updated for Factory AI users\"\n    echo \"\"\n    echo \"Recommended next step:\"\n    echo \"  \u002Faiwg-update-agents-md\"\n    echo \"\"\n  else\n    echo \"⚠️  Factory AI droids detected but aiwg-update-agents-md command not found\"\n    echo \"   Install latest AIWG version for Factory AI support\"\n  fi\n\n  echo \"=======================================================================\"\nfi\n```\n\n**Cross-Platform Integration**:\n- **Claude Code only**: Updates CLAUDE.md\n- **Claude Code + Factory AI**: Updates CLAUDE.md, recommends updating AGENTS.md\n- **Multi-platform**: User should run platform-specific commands for each platform\n\nUse Bash tool for Factory AI detection.\n\n## Intelligent Content Preservation\n\n### User Content Indicators\n\n**These sections are ALWAYS preserved**:\n\n- `# CLAUDE.md` (header)\n- `## Repository Purpose` (and its content)\n- Any custom `##` headings (not \"## AIWG\")\n- `## Project-Specific Notes` (footer section)\n- Custom tool configurations\n- Team-specific rules\n\n**Example existing CLAUDE.md**:\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\nThis is a financial trading platform built with Python and FastAPI.\n\n## Team Rules\n\n- All commits must be signed\n- Use black for formatting\n- Run tests before pushing\n\n## AIWG SDLC Framework\n\n{...old AIWG section...}\n\n## Deployment Notes\n\n- Production deploys require approval\n- Staging auto-deploys from main\n```\n\n**After update**:\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\nThis is a financial trading platform built with Python and FastAPI.\n\n## Team Rules\n\n- All commits must be signed\n- Use black for formatting\n- Run tests before pushing\n\n---\n\n## AIWG SDLC Framework\n\n{...NEW orchestration guidance from template...}\n\n---\n\n## Deployment Notes\n\n- Production deploys require approval\n- Staging auto-deploys from main\n```\n\n### Edge Cases\n\n**Case 1: AIWG section at end of file**\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\n...\n\n## AIWG SDLC Framework\n\n{...old section...}\n```\n\n**Action**: Replace AIWG section through EOF\n\n**Case 2: Multiple user sections after AIWG**\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\n...\n\n## AIWG SDLC Framework\n\n{...old section...}\n\n## Deployment Notes\n\n...\n\n## Security Rules\n\n...\n```\n\n**Action**: Replace AIWG section, preserve all user sections after\n\n**Case 3: No AIWG section (first time setup)**\n\n```markdown\n# CLAUDE.md\n\n## Repository Purpose\n\n...\n\n## Team Rules\n\n...\n```\n\n**Action**: Insert AIWG section after Repository Purpose, before Team Rules\n\n## Output Format\n\nProvide clear status report:\n\n```markdown\n# CLAUDE.md Update Complete\n\n**Project**: {project-directory}\n**AIWG Installation**: {AIWG_ROOT}\n**Operation**: {UPDATED | INSERTED}\n\n## Changes Made\n\n### AIWG Section\n- {UPDATED | INSERTED} AIWG framework documentation\n- ✓ Added Core Platform Orchestrator Role guidance\n- ✓ Added Natural Language Command Translation map\n- ✓ Added Multi-Agent Orchestration Pattern\n- ✓ Updated command reference to latest flows\n- ✓ Substituted AIWG_ROOT: {actual-path}\n\n### User Content Preserved\n- ✓ Repository Purpose section preserved\n- ✓ Custom team rules preserved\n- ✓ {N} custom sections preserved\n- {List any custom sections found}\n\n## Validation Results\n\n{validation checklist from Step 7}\n\n## What's New in This Update\n\n**Orchestration Architecture**:\n- Core platform (Claude Code) is now the orchestrator, not command executor\n- Flow commands are templates, not bash scripts to run\n- Multi-agent coordination pattern documented\n\n**Natural Language Support**:\n- Users can use natural language instead of slash commands\n- Translation map for common phrases (\"transition to Elaboration\", etc.)\n- Intent recognition patterns documented\n\n**Multi-Agent Workflow**:\n- Primary Author → Parallel Reviewers → Synthesizer → Archive pattern\n- Parallel execution guidance (single message, multiple Task calls)\n- Progress tracking with ✓ ⏳ ❌ symbols\n\n**Enhanced Guidance**:\n- --guidance and --interactive parameter support\n- Phase-specific workflow patterns\n- Troubleshooting and common patterns\n\n## Next Steps\n\n1. **Review Updated Sections**: Read through the new AIWG orchestration guidance\n2. **Test Natural Language**: Try \"Let's transition to Elaboration\" instead of slash commands\n3. **Deploy Latest Agents**: Run `aiwg -deploy-agents --mode sdlc` if needed\n4. **Check Flow Commands**: Ensure `.claude\u002Fcommands\u002Fflow-*.md` are deployed\n\n{if Factory AI detected}\n5. **Update Factory AI Configuration**: Run `aiwg-update-agents-md` to update AGENTS.md with project-specific content for Factory AI users\n\n## Backup\n\nA backup of your previous CLAUDE.md has been saved to:\n  {CLAUDE_MD}.backup-{timestamp}\n\nTo restore: `cp {CLAUDE_MD}.backup-{timestamp} {CLAUDE_MD}`\n```\n\n## Error Handling\n\n**CLAUDE.md Not Found**:\n\n```markdown\n❌ Error: No CLAUDE.md found at {path}\n\nFor new projects, use:\n  \u002Faiwg-setup-project\n\nFor projects that never had CLAUDE.md, create one first or use aiwg-setup-project.\n```\n\n**AIWG Template Not Found**:\n\n```markdown\n❌ Error: AIWG template not found at {CLAUDE_TEMPLATE}\n\nPlease update AIWG installation:\n  aiwg -update\n\nOr reinstall:\n  aiwg -reinstall\n```\n\n**Merge Conflict**:\n\n```markdown\n⚠️  Warning: Could not automatically merge AIWG section\n\nManual review required. The file structure is unexpected.\n\nPlease review:\n  {CLAUDE_MD}\n\nBackup saved to:\n  {CLAUDE_MD}.backup-{timestamp}\n```\n\n## Success Criteria\n\nThis command succeeds when:\n\n- [ ] Existing CLAUDE.md read successfully\n- [ ] AIWG template loaded and AIWG_ROOT substituted\n- [ ] All user content identified and preserved\n- [ ] AIWG section updated with latest orchestration guidance\n- [ ] Backup created before modifications\n- [ ] Validation checks pass\n- [ ] Clear summary provided to user\n\n## Implementation Notes\n\n**Use Read tool** to:\n\n- Read existing CLAUDE.md\n- Read AIWG template\n- Identify section boundaries\n\n**Use Edit tool** to:\n\n- Replace existing AIWG section\n- Insert AIWG section if missing\n- Preserve all user content\n\n**Use Bash tool** to:\n\n- Create backup with timestamp\n- Validate AIWG installation\n- Check file permissions\n\n**DO NOT**:\n\n- Delete or overwrite user content\n- Lose custom sections\n- Remove project-specific rules\n- Skip backup creation\n\n## Key Differences from aiwg-setup-project\n\n| Feature | aiwg-setup-project | aiwg-update-claude |\n|---------|-------------------|-------------------|\n| Target | New projects or first-time setup | Existing projects with CLAUDE.md |\n| Operation | Create or append AIWG section | Intelligently replace AIWG section |\n| User Content | May not exist yet | MUST be preserved |\n| Backup | Optional | ALWAYS created |\n| Validation | Basic checks | Comprehensive validation |\n| Use Case | Initial setup | Update to latest guidance |\n\n## References\n\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fhuman-authorization.md — Always create a backup before modifying CLAUDE.md; never silently overwrite user content\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fagent-deployment.md — Rules for working with agent definitions and multi-provider deployment\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Frules\u002Fresearch-before-decision.md — Read existing CLAUDE.md and identify section boundaries before acting\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fskills\u002Faiwg-setup-project\u002FSKILL.md — Initial setup skill; use this skill for subsequent updates\n- @$AIWG_ROOT\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fskills\u002Faiwg-update-agents-md\u002FSKILL.md — Companion skill to invoke when Factory AI is also detected\n",{"name":5,"namespace":55,"platforms":56,"commandHint":58,"description":7},"aiwg",[57],"all",{"model":45,"category":59,"modelRole":38,"modelTier":60,"allowedTools":61,"argumentHint":62},"sdlc-setup","economy","Read, Write, Edit, Bash",[63],"project-directory --interactive --guidance \"text\"","main","6754967c344ccb087a8de06972f55a41067b291b","agentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fskills\u002Faiwg-update-claude",36,"https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg","https:\u002F\u002Faiwg.io","https:\u002F\u002Fgithub.com\u002Fjmagly","https:\u002F\u002Fintegrolabs.io","ml\u002Fai, industrial automation, safety\u002Fsecurity, ssi\r\n\r\nmagly.net\r\nintegrolabs.io\r\naiwg.io\r\nfortemi.com\r\npagenary.com\r\nbytecask.com","2026-11-14 10:46:34",{"source":9,"skillName":5,"commands":75,"prompt":85,"zipAvailable":86},[76,79,82],{"tool":77,"command":78},"npx","npx skills add jmagly\u002Faiwg --skill aiwg-update-claude",{"tool":80,"command":81},"bunx","bunx skills add jmagly\u002Faiwg --skill aiwg-update-claude",{"tool":83,"command":84},"pnpm","pnpm dlx skills add jmagly\u002Faiwg --skill aiwg-update-claude","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsdlc-complete\u002Fskills\u002Faiwg-update-claude\u002FSKILL.md",true,[],[89,97,102,127,146,151],{"skillNo":90,"name":91,"nameZh":17,"description":92,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":96},"01M78KW7PZJ9YQZQMW84SN2YD4","plugin-search","Search marketplaces for plugins using configured local manifests and directory caches; rank matching plugins by observed installs, review tier and cache dates without installing or fetching anything","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Futils\u002Fskills\u002Fplugin-search\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":98,"name":91,"nameZh":17,"description":92,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":96},"01M78KSEZS9ZNNFESY9ANW22S0","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Faddons\u002Faiwg-utils\u002Fskills\u002Fplugin-search\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":17,"description":105,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":50},"01M70QA0BSYJ49EES9V4RE8QH1","host-hardening","Read-only system hardening baseline and plan-first host hardening recommendations for SSH, Docker bind addresses, firewall persistence, datastores, exporters and audit retention.","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fsecurity-engineering\u002Fskills\u002Fhost-hardening\u002FSKILL.md",[],[109,110,111,112,113,44,114,115,116,117,118,119,120,47,121,122,123,124,125,126],"hardening","host","host hardening","verification","secrets","request","remediation","recommendations","audit","plan","port","bind","access","only","retention","re","never","firewall",{"skillNo":128,"name":129,"nameZh":17,"description":130,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":50},"01M70PNT2Z4HMZPRBTAF6073NN","exposure-analysis","Read-only firewall analysis and effective host exposure reconstruction for Docker published ports, UFW bypass, stale rules, CDN scope, IPv6 asymmetry and external probe allowlists.","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fplugins\u002Fforensics\u002Fskills\u002Fexposure-analysis\u002FSKILL.md",[],[134,135,136,137,138,43,44,139,119,125,47,140,110,141,122,142,143,126,144,145],"analysis","exposure analysis","collection","reconstruction","operator","credentials","unknown","internet","local","scope","ports","ufw",{"skillNo":147,"name":104,"nameZh":17,"description":105,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":50},"01M70P8QATMPKA78E4FT5D2TNA","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fsecurity-engineering\u002Fskills\u002Fhost-hardening\u002FSKILL.md",[],[109,110,111,124,125,126,120,123,116,113,44,114,115,117,118,119,112,47,121,122],{"skillNo":152,"name":129,"nameZh":17,"description":130,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":153,"categories":154,"keywords":155,"publishedAt":50},"01M70NMPVJ5H0JH131P60FW4R8","https:\u002F\u002Fgithub.com\u002Fjmagly\u002Faiwg\u002Fblob\u002Fmain\u002Fagentic\u002Fcode\u002Fframeworks\u002Fforensics-complete\u002Fskills\u002Fexposure-analysis\u002FSKILL.md",[],[134,135,145,144,138,143,142,122,137,43,44,139,119,136,47,140,110,126,125,141]]