AgentSkillsCN

document.readme.update

根据代码变更,对现有README.md进行动态更新。分析Git差异,精准定位受影响的章节并同步相关内容。细致检测徽章、版本号、依赖项、命令、API接口及整体结构的变化,仅对受变更影响的部分进行准确更新。当用户提出“更新README”、“同步README”、“刷新文档”或“在代码变更后更新README”时,此技能便能助您高效完成任务。

SKILL.md
--- frontmatter
name: document.readme.update
description: 'Update an existing README.md based on code changes. Analyze git diff, identify impacted sections, and sync content. Detect changes to badges, versions, dependencies, commands, API, and structure, and update only affected sections accurately. Use when asked to "update README", "sync README", "refresh docs", or update README after code changes.'

README.md Update Skill

This skill synchronizes an existing README.md with the latest code changes.

When to Use This Skill

  • Refreshing README.md after code changes
  • Checking README.md accuracy before PR/MR
  • Updating docs after dependency/script updates
  • Updating badges/text after version changes

Prerequisites

  • README.md exists in the project root
  • Changes are tracked in a Git repository

Step-by-Step Workflows

Workflow 1: Diff-Based Update

  1. Check change diff

    • Use #changes to get Git diffs (staged/unstaged)
    • Classify changed files
  2. Impact analysis

    • Decide whether README updates are needed using the matrix below
  3. Load existing README

    • Use #readFile to inspect current section structure/content
    • Record section start/end lines
  4. Update by section

    • Update only impacted sections
    • Do not change other sections
    • Use #editFiles to edit only target sections
  5. Consistency checks

    • Validate badge URLs
    • Confirm commands in code blocks are up to date
    • Validate internal links (anchors/file links)
  6. Report results

    • Output a summary of updated section diffs

Workflow 2: Full Review Update

  1. Read current full README.md with #readFile
  2. Analyze latest project state with document.readme.analyze
  3. Compare each section against current project state
  4. Identify outdated/misaligned sections
  5. Apply section-level updates

Impact Matrix

Impact by Changed File Type

Changed FileImpacted README Sections
package.json (dependencies)Installation, Prerequisites
package.json (scripts)Usage, Testing, Development
package.json (version)Badges
tsconfig.json / build configInstallation, Development
.github/workflows/*Badges (CI status)
Dockerfile / docker-compose.ymlInstallation, Deployment
.env.exampleConfiguration (environment vars)
Source code under src/Usage, API Reference
LICENSELicense
Added/removed directoriesDirectory Structure
New Agent/Skill/PromptFeatures, Usage, Directory Structure

Impact by Change Type

Change TypeREADME Update Needed
Comments/JSDoc only
Formatting/indentation
Type annotation changes
Internal refactoring (no external interface change)
Dependency add/remove
npm script changes
CLI command changes
API endpoint additions/changes
Environment variable additions/changes
New feature added
Directory structure changes
License changes
Version changes

Section Update Templates

Version / Badge Update

markdown
<!-- Before -->
[![npm version](https://badge.fury.io/js/package%40old-version.svg)]()

<!-- After -->
[![npm version](https://badge.fury.io/js/package%40new-version.svg)]()

Environment Variable Section Update

When a new environment variable is detected from diffs:

markdown
## ⚙️ Configuration

| Environment Variable | Description | Default | Required |
|----------------------|-------------|---------|:--------:|
| `EXISTING_VAR` | Existing variable | `default` | ✅ |
| `NEW_VAR` | **New** - Description | - | ✅ |

Directory Structure Update

When new directories/files are added:

markdown
## 📁 Directory Structure

\```
project/
├── src/
├── tests/
├── new-directory/    # <- newly added
└── README.md
\```

Update Log

When README is updated, append this comment format at the end (optional):

markdown
<!-- README last updated: YYYY-MM-DD -->
<!-- Updated sections: Installation, Environment Variables -->

Troubleshooting

ProblemSolution
Unsure which sections to updateUse impact matrix
Changes are too broadConsider full rewrite with readme.generate
README does not existCreate new one with readme.generate
Broken badge URLsRegenerate URLs via shields.io
Markdown syntax errorsValidate with markdownlint