AgentSkillsCN

upgrade

自我提升系统,用于发现并应用AIProject的更新。

SKILL.md
--- frontmatter
name: upgrade
version: 1.0.0
description: Self-improvement system for discovering and applying updates to AIProjects
category: maintenance
tags: [self-improvement, updates, monitoring, automation]
created: 2026-01-21
context: shared
model: sonnet

Upgrade Skill

A self-improvement system that monitors external sources for updates to Claude Code, libraries, and infrastructure components, then proposes and implements improvements to AIProjects.

Inspiration: Daniel Miessler's PAI v2 - "Within 5 minutes, the entire Kai system was upgraded with this piece of functionality."


Overview

AspectDescription
PurposeProactively discover and apply improvements to AIProjects
PatternSKILL.md + config + data files (current pattern)
When to UseRegular maintenance, after Claude Code releases, when exploring improvements
TELOS LinkG-T1 (Infrastructure Maturity), G-T3 (AI Assistant Context Depth)

Quick Actions

NeedActionCommand
Find updatesCheck sources for new releases/upgrade discover
Evaluate relevanceScore and prioritize discoveries/upgrade analyze
Get proposalGenerate implementation plan/upgrade propose
Apply upgradeImplement approved change/upgrade implement <id>
Check statusView pending/recent upgrades/upgrade status
View historySee past upgrades/upgrade history
Undo changeRollback an upgrade/upgrade rollback <id>

Workflow

code
+---------------------------------------------------------------------+
|                      UPGRADE SKILL WORKFLOW                          |
+---------------------------------------------------------------------+
|  PHASE 1: DISCOVER                                                   |
|  /upgrade discover                                                   |
|     - Fetch sources from config.yaml                                 |
|     - Compare against baselines.json                                 |
|     - Identify new/changed items                                     |
|     - Store discoveries in pending-upgrades.json                     |
+---------------------------------------------------------------------+
|  PHASE 2: ANALYZE                                                    |
|  /upgrade analyze                                                    |
|     - Read AIProjects current state (.claude/*, CLAUDE.md)           |
|     - Evaluate each discovery for relevance                          |
|     - Score impact (1-10) and complexity (Low/Med/High)              |
|     - Prioritize by value/effort ratio                               |
+---------------------------------------------------------------------+
|  PHASE 3: PROPOSE                                                    |
|  /upgrade propose [id]                                               |
|     - Generate specific implementation proposals                     |
|     - Identify files to modify                                       |
|     - Note risks and rollback strategy                               |
|     - Present for user approval                                      |
+---------------------------------------------------------------------+
|  PHASE 4: IMPLEMENT                                                  |
|  /upgrade implement <id>                                             |
|     - Create git checkpoint (tag/branch)                             |
|     - Apply changes (edit files, update configs)                     |
|     - Run validation (hooks, tests if applicable)                    |
|     - Log to upgrade-history.jsonl                                   |
+---------------------------------------------------------------------+
|  PHASE 5: VERIFY & LEARN                                             |
|  Automatic via hooks                                                 |
|     - Capture learning if significant                                |
|     - Update Memory MCP with decision                                |
|     - Store in TELOS if goal-relevant                                |
+---------------------------------------------------------------------+

Sources to Monitor

Priority 1: Critical (Check Daily)

SourceTypeWhat to Extract
Claude Code ReleasesGitHub APIVersion, changelog, breaking changes
Security AdvisoriesGitHub SecurityCVEs, patches, mitigations
Claude Code DocsDocumentationNew features, API changes

Priority 2: Important (Check Weekly)

SourceTypeWhat to Extract
Anthropic Engineering BlogBlogTechniques, best practices
Claude Code DiscussionsGitHubCommunity solutions, workarounds
MCP Servers RegistryGitHubNew MCP servers, updates

Priority 3: Supplementary (Check Bi-Weekly)

SourceTypeWhat to Extract
Anthropic YouTubeVideosTutorials, feature demos
Claude API ChangelogDocumentationAPI changes affecting MCP

Source configuration: See config.yaml for URLs and parsing details.


Discovery Workflow

Process (uses existing tools)

  1. Fetch sources using WebFetch tool

    code
    WebFetch: https://api.github.com/repos/anthropics/claude-code/releases
    Extract: version, tag_name, body (changelog), published_at
    
  2. Compare against baselines

    • Read data/baselines.json for current known versions
    • Identify items where fetched version > baseline version
    • Flag new items not in baseline
  3. Store discoveries

    • Write new items to data/pending-upgrades.json
    • Include: source, type, title, summary, URLs
  4. Generate report

    • Use templates/discovery-report.md
    • Show count by priority, highlight critical items

Example Discovery Session

bash
/upgrade discover

# Output:
Discovery Report - 2026-01-21
=============================
Sources checked: 6
New discoveries: 3

CRITICAL:
- [UP-004] Claude Code 2.2.1 released (security patch)

HIGH:
- [UP-005] New hook event: PreToolUse validation

MEDIUM:
- [UP-006] MCP Gateway updated to 1.2.0

Run /upgrade analyze to evaluate relevance.

Analysis Workflow

Relevance Scoring Criteria

FactorPointsDescription
Category Match+3Affects hooks/skills/commands/MCP we use
Recency+2 maxNewer = higher (decay over 30 days)
Security+3Security-related update
Breaking Change-2Has breaking changes
Dependencies+1Updates our dependencies

Score Interpretation:

  • 8-10: Critical - Auto-notify, apply soon
  • 6-7: High - Include in next session
  • 4-5: Medium - Include in weekly review
  • 1-3: Low - Log but don't notify

Impact Levels

LevelDescriptionExample
CRITICALSecurity vulnerability, data loss riskCVE patch
HIGHSignificant functionality improvementNew hook events
MEDIUMUseful enhancementPerformance improvement
LOWNice to haveDocumentation update

Complexity Levels

LevelDescriptionEffort
LOWConfig change only< 5 min
MEDIUMCode/file modifications15-30 min
HIGHArchitectural changes> 1 hour

Proposal Workflow

Proposal Structure

Each proposal includes:

  1. Summary: What the upgrade does
  2. Relevance: Why it matters to AIProjects
  3. Files to Modify: Specific paths and changes
  4. Risks: What could go wrong
  5. Rollback Strategy: How to undo
  6. Estimated Effort: Time to implement

Risk Assessment

Risk LevelDescriptionAction
LowConfig-only, easily reversibleProceed
MediumCode changes, tested rollbackReview before proceed
HighBreaking changes, complex rollbackDetailed review required
CriticalSecurity implicationsManual review mandatory

Implementation Workflow

Pre-Implementation Checklist

  • Proposal approved by user
  • Git working directory clean
  • Checkpoint tag created: pre-UP-xxx
  • Files to modify identified
  • Rollback command ready

Implementation Steps

  1. Create checkpoint

    bash
    git tag pre-UP-xxx -m "Checkpoint before upgrade UP-xxx"
    
  2. Apply changes

    • Edit files as specified in proposal
    • Update configs if needed
    • Run any required commands
  3. Validate

    • Existing hooks run automatically
    • Check for errors in modified files
    • Verify functionality if applicable
  4. Log

    • Append to data/upgrade-history.jsonl
    • Update data/baselines.json
    • Remove from data/pending-upgrades.json

Post-Implementation

  • Memory MCP: Store decision with rationale
  • TELOS: Update relevant goal if applicable
  • Commit: Include upgrade ID in commit message

Data Files

baselines.json

Current known versions for comparison:

json
{
  "version": "1.0",
  "components": {
    "claude-code": { "version": "2.1.14" },
    "mcp-git": { "version": "1.0.0" }
  }
}

pending-upgrades.json

Discovered but not yet applied:

json
{
  "upgrades": [
    {
      "id": "UP-001",
      "source": "claude-code-releases",
      "title": "Claude Code 2.2.0",
      "relevance_score": 9,
      "status": "pending_review"
    }
  ]
}

upgrade-history.jsonl

Audit trail of all upgrades:

json
{"id":"UP-001","timestamp":"2026-01-21","status":"applied","rollback_tag":"pre-UP-001"}

Rollback Procedure

Automatic Rollback (on failure)

If implementation fails:

  1. Detect error condition
  2. Run git checkout pre-UP-xxx -- .
  3. Log failure to history
  4. Notify user

Manual Rollback

bash
/upgrade rollback UP-xxx

# Process:
1. Verify tag exists: pre-UP-xxx
2. Restore files from tag
3. Update history with rollback status
4. Remove from pending if re-added

Integration Points

IntegrationHow It Works
Memory MCPStores upgrade decisions, rationale, and learnings
TELOSLinks upgrades to G-T1 (Infrastructure Maturity)
OrchestrationComplex upgrades spawn /orchestration:plan
HooksPost-upgrade validation via existing hooks
Git MCPVersion control, checkpoints, rollbacks

Best Practices

Do

  • Run /upgrade discover weekly at minimum
  • Review proposals before implementing
  • Keep baselines.json updated
  • Document why upgrades were deferred

Don't

  • Apply upgrades without reading the proposal
  • Skip the checkpoint step
  • Ignore breaking change warnings
  • Apply multiple upgrades at once (unless bundled)

Troubleshooting

IssueCauseSolution
Discovery returns emptyRate limited or source downWait and retry, check source URLs
Wrong relevance scoreMissing contextRun analyze again after updating AIProjects state
Rollback failsTag missingCheck git tags, may need manual restore
Upgrade breaks somethingBreaking change missedRollback, review changelog more carefully

Scheduled/Headless Execution

The upgrade discovery workflow can run autonomously on a schedule.

Quick Start

bash
# Test the scheduled job (dry run)
~/.claude/jobs/claude-scheduled.sh upgrade-discover --dry-run

# Run discovery headlessly
~/.claude/jobs/claude-scheduled.sh upgrade-discover --verbose

# View output
cat ~/.claude/logs/scheduled/upgrade-discover-*.json | tail -1 | jq '.result'

Cron Schedule

bash
# Weekly discovery - Sunday 6:00 AM
0 6 * * 0 <project_root>/.claude/jobs/claude-scheduled.sh upgrade-discover

How It Works

  1. Wrapper script (claude-scheduled.sh) configures environment and permissions
  2. Claude Code CLI runs with -p flag (non-interactive mode)
  3. Permission tier limits to "analyze" (read + write data files)
  4. Output is captured as JSON and logged
  5. Discoveries are written to pending-upgrades.json
  6. Next session shows pending discoveries via session-start hook

Permission Tier: Analyze

The scheduled job uses the "analyze" tier which allows:

  • Reading files (baselines, config, existing data)
  • Fetching external sources (GitHub, docs, blogs)
  • Writing to data files (pending-upgrades.json)

It does NOT allow:

  • Editing code files
  • Git commits
  • Implementing upgrades

Implementation still requires interactive approval.

Monitoring

bash
# Check recent runs
ls -la ~/.claude/logs/scheduled/upgrade-discover-*.log

# View costs
grep "Cost:" ~/.claude/logs/scheduled/upgrade-discover-*.log

# Check for alerts
cat ~/.claude/logs/scheduled/alerts.log

See @.claude/context/patterns/autonomous-execution-pattern.md for full documentation.


Related