Agent Workspace Manager
Overview
This skill provides a systematic approach to organizing and maintaining agent workspace directories. It ensures documents are placed in appropriate functional directories, detects structure issues, and maintains content freshness.
Core Capabilities
1. Structure Initialization
Initialize a standardized workspace structure for new agents:
CODEBLOCK0
Usage: When setting up a new workspace, create this structure to enable efficient information retrieval.
2. Document Classification
Every document must be placed in a directory matching its functional purpose:
| Document Type | Directory | Characteristics |
|---|
| Events, conversations, time-based records | INLINECODE0 | Has timestamp, may expire |
| Domain knowledge, technical docs |
knowledge/ | Stable, long-term valid |
|
Core business SQL |
knowledge/sql/ |
Long-term used SQL |
| Tasks, todos, project items |
tasks/ | Temporary, project-bound |
| Important choices with rationale |
decisions/ | Decision history, traceable |
| User habits, preferences |
preferences/ | Personalization config |
| Expired but valuable content |
archives/ | Preserved for reference |
|
Historical SQL versions |
archives/sql_versions/ |
Deprecated SQL |
| Reusable patterns, templates |
templates/ | Copy-paste ready |
|
Reusable SQL templates |
templates/sql/ |
Standard queries |
|
Scripts (.py, .sh) |
scripts/ |
Utility scripts |
Classification Rule: Before creating any document, determine its primary function. Place it in the matching directory. Never place files in incorrect directories.
3. Code File Classification (NEW)
Code files (SQL, Python, Shell, etc.) must follow these rules:
| File Type | Directory | Purpose |
|---|
| INLINECODE11 (core business) | INLINECODE12 | Long-term used SQL queries |
| INLINECODE13 (templates) |
templates/sql/ | Reusable standard queries |
|
.sql (historical) |
archives/sql_versions/ | Deprecated SQL versions |
|
.py (scripts) |
scripts/ | Python utility scripts |
|
.sh (scripts) |
scripts/ | Shell utility scripts |
|
.json (config) |
config/ or root | Configuration files |
SQL File Naming Rules:
- - ✅ DO: Use semantic names: INLINECODE23
- ❌ DON'T: Use version suffixes:
神策宽表转JSON_v1.sql, INLINECODE25 - ❌ DON'T: Use functional suffixes:
神策宽表转JSON_修正版.sql, INLINECODE27
When to Create New Version:
- - If SQL needs update, modify the existing file
- Archive old version to
archives/sql_versions/ with timestamp if needed - Keep only ONE active version in INLINECODE29
4. Workspace Health Check
Run health checks to identify issues:
- - Misplaced files: Documents in wrong directories
- Duplicates: Similar content in multiple files
- Code file duplicates: Multiple versions of same SQL/script (NEW)
- Stale content: Outdated information that needs refresh
- Orphan files: Files without clear purpose or references
- Naming violations: Files with version suffixes (NEW)
Output: A report with specific file recommendations.
5. Duplicate File Detection (ENHANCED)
Detect duplicate files using these methods:
For Document Files (.md)
- 1. Name similarity: Files with similar names (e.g.,
report-v1.md and report-v2.md) - Content similarity: Files with >80% content overlap
- Functional similarity: Files serving the same purpose
For Code Files (.sql, .py, .sh)
- 1. Version suffixes: Files with
_v1, _v2, _final, _修正版, _完整版 etc. - Same functionality: Multiple SQL files for the same transformation/query
- Timestamp in name: Files with timestamps that could be archived
Detection Command:
CODEBLOCK1
6. Content Freshness Maintenance
Maintain document freshness through:
- 1. Merge: Combine duplicate or similar files, preserving all key information
- Archive: Move expired content to
archives/ with timestamp - Refresh: Update stale knowledge with latest information
- Prune: Remove truly redundant content (only when no key info is lost)
- Consolidate: Merge multiple versions into one, archive old versions (NEW)
Safety Principle: Never delete content that might contain unique valuable information. Archive instead.
7. Structure Extension Detection
When existing directories cannot accommodate new functional needs:
- 1. Detect: Identify documents that don't fit current categories
- Propose: Suggest new directories or structure reorganization
- Implement: Create new directories following naming conventions
- Document: Update this skill's structure reference
Example: If knowledge/ grows too large with mixed domain types, split into knowledge/product/, knowledge/technical/, knowledge/business/.
Workflow
For New Workspace Setup
- 1. Determine agent type (personal assistant, project manager, knowledge base, etc.)
- See references/structure-templates.md for appropriate template
- Create directories and initial files
- Set up MEMORY.md as the entry point
For Workspace Audit
- 1. Scan all files in workspace
- Classify each file by function
- Check for misplaced files
- Detect duplicate files (including code files)
- Generate health report
- Propose fixes for user approval
For Content Cleanup
- 1. Identify duplicates/similar files
- Detect version-suffixed files (NEW)
- Propose merge candidates
- Identify expired content
- Archive with preservation
- Verify no key information is lost
For Code File Cleanup (NEW)
- 1. Scan all code files (.sql, .py, .sh)
- Identify files with version suffixes
- Determine the latest/best version
- Keep latest in appropriate directory (knowledge/sql/ or templates/sql/)
- Archive old versions to archives/sql_versions/
- Remove version suffixes from filenames
Resources
references/
- - structure-templates.md - Pre-defined workspace templates for different agent types
- classification-rules.md - Detailed rules for document classification (UPDATED)
Multi-Agent Sharing
This skill is designed to be copyable across agents:
- 1. Install the same skill in multiple agent workspaces
- Each agent follows the same structure conventions
- Shared knowledge can be exchanged between agents
- Consistent structure enables cross-agent collaboration
Changelog
v1.1 (2026-03-25)
- - Added code file classification rules (SQL, Python, Shell)
- Added duplicate file detection methods
- Added file naming best practices
- Enhanced workspace health check to detect version-suffixed files
- Added SQL-specific cleanup workflow
Agent Workspace Manager
概述
本技能提供了一种系统化的方法来组织和管理代理工作空间目录。它确保文档被放置在合适的功能目录中,检测结构问题,并维护内容的时效性。
核心能力
1. 结构初始化
为新代理初始化标准化的工作空间结构:
workspace/
├── MEMORY.md # 核心记忆索引(代理首先读取此文件)
├── memory/ # 基于时间的记忆片段
├── knowledge/ # 稳定的领域知识
│ └── sql/ # 核心业务SQL(新增)
├── tasks/ # 临时/项目特定事项
├── decisions/ # 包含理由的决策记录
├── preferences/ # 用户偏好和设置
├── archives/ # 已过期但保留的内容
│ └── sql_versions/ # 历史SQL版本(新增)
├── templates/ # 可复用模板
│ └── sql/ # 可复用SQL模板(新增)
└── scripts/ # 脚本和工具(新增)
用法: 设置新工作空间时,创建此结构以实现高效的信息检索。
2. 文档分类
每个文档必须放置在与功能目的匹配的目录中:
| 文档类型 | 目录 | 特征 |
|---|
| 事件、对话、基于时间的记录 | memory/ | 有时间戳,可能过期 |
| 领域知识、技术文档 |
knowledge/ | 稳定、长期有效 |
|
核心业务SQL | knowledge/sql/ |
长期使用的SQL |
| 任务、待办事项、项目事项 | tasks/ | 临时、项目相关 |
| 包含理由的重要选择 | decisions/ | 决策历史、可追溯 |
| 用户习惯、偏好 | preferences/ | 个性化配置 |
| 已过期但有价值的内容 | archives/ | 保留以供参考 |
|
历史SQL版本 | archives/sql_versions/ |
已弃用的SQL |
| 可复用模式、模板 | templates/ | 可直接复制粘贴 |
|
可复用SQL模板 | templates/sql/ |
标准查询 |
|
脚本(.py, .sh) | scripts/ |
工具脚本 |
分类规则: 在创建任何文档之前,确定其主要功能。将其放置在匹配的目录中。切勿将文件放置在错误的目录中。
3. 代码文件分类(新增)
代码文件(SQL、Python、Shell等)必须遵循以下规则:
| 文件类型 | 目录 | 用途 |
|---|
| .sql(核心业务) | knowledge/sql/ | 长期使用的SQL查询 |
| .sql(模板) |
templates/sql/ | 可复用的标准查询 |
| .sql(历史) | archives/sql_versions/ | 已弃用的SQL版本 |
| .py(脚本) | scripts/ | Python工具脚本 |
| .sh(脚本) | scripts/ | Shell工具脚本 |
| .json(配置) | config/ 或根目录 | 配置文件 |
SQL文件命名规则:
- - ✅ 应做: 使用语义化名称:神策宽表转JSON.sql
- ❌ 不应做: 使用版本后缀:神策宽表转JSONv1.sql、神策宽表转JSON最终版.sql
- ❌ 不应做: 使用功能后缀:神策宽表转JSON修正版.sql、神策宽表转JSON完整版.sql
何时创建新版本:
- - 如果SQL需要更新,修改现有文件
- 如有需要,将旧版本归档到 archives/sql_versions/ 并添加时间戳
- 在 knowledge/sql/ 中仅保留一个活跃版本
4. 工作空间健康检查
运行健康检查以识别问题:
- - 文件放错位置: 文档在错误的目录中
- 重复文件: 多个文件中存在相似内容
- 代码文件重复: 同一SQL/脚本的多个版本(新增)
- 过时内容: 需要更新的过时信息
- 孤立文件: 没有明确用途或引用的文件
- 命名违规: 带有版本后缀的文件(新增)
输出: 包含具体文件建议的报告。
5. 重复文件检测(增强)
使用以下方法检测重复文件:
对于文档文件(.md)
- 1. 名称相似性: 名称相似的文件(例如 report-v1.md 和 report-v2.md)
- 内容相似性: 内容重叠超过80%的文件
- 功能相似性: 服务于相同目的的文件
对于代码文件(.sql, .py, .sh)
- 1. 版本后缀: 带有 v1、v2、final、修正版、_完整版 等的文件
- 相同功能: 用于同一转换/查询的多个SQL文件
- 名称中的时间戳: 带有时间戳且可能已归档的文件
检测命令:
bash
查找带有版本后缀的SQL文件
find . -name *.sql -type f | grep -E (
v[0-9]|最终|
完整|修正|_修复)
按名称模式查找重复的MD文件
find . -name *.md -type f | grep -E (
v[0-9]|最终|_完整)
6. 内容时效性维护
通过以下方式维护文档的时效性:
- 1. 合并: 合并重复或相似的文件,保留所有关键信息
- 归档: 将过期内容移动到 archives/ 并添加时间戳
- 更新: 用最新信息更新过时的知识
- 精简: 删除真正冗余的内容(仅当不丢失关键信息时)
- 整合: 将多个版本合并为一个,归档旧版本(新增)
安全原则: 切勿删除可能包含独特有价值信息的内容。改为归档。
7. 结构扩展检测
当现有目录无法满足新的功能需求时:
- 1. 检测: 识别不适合当前分类的文档
- 建议: 提出新目录或结构重组方案
- 实施: 按照命名约定创建新目录
- 记录: 更新本技能的结构参考
示例: 如果 knowledge/ 因混合领域类型而变得过大,可拆分为 knowledge/product/、knowledge/technical/、knowledge/business/。
工作流程
新工作空间设置
- 1. 确定代理类型(个人助理、项目经理、知识库等)
- 查看 references/structure-templates.md 获取合适的模板
- 创建目录和初始文件
- 将 MEMORY.md 设置为入口点
工作空间审计
- 1. 扫描工作空间中的所有文件
- 按功能对每个文件进行分类
- 检查放错位置的文件
- 检测重复文件(包括代码文件)
- 生成健康报告
- 提出修复建议供用户批准
内容清理
- 1. 识别重复/相似文件
- 检测带有版本后缀的文件(新增)
- 提出合并候选方案
- 识别过期内容
- 归档并保留
- 验证未丢失关键信息
代码文件清理(新增)
- 1. 扫描所有代码文件(.sql, .py, .sh)
- 识别带有版本后缀的文件
- 确定最新/最佳版本
- 将最新版本保留在适当目录中(knowledge/sql/ 或 templates/sql/)
- 将旧版本归档到 archives/sql_versions/
- 从文件名中移除版本后缀
资源
references/
- - structure-templates.md - 针对不同代理类型的预定义工作空间模板
- classification-rules.md - 文档分类的详细规则(已更新)
多代理共享
本技能设计为可在多个代理间复制:
- 1. 在多个代理工作空间中安装相同的技能
- 每个代理遵循相同的结构约定
- 共享知识可在代理间交换
- 一致的结构支持跨代理协作
更新日志
v1.1(2026-03-25)
- - 添加了代码文件分类规则(SQL、Python、Shell)
- 添加了重复文件检测方法
- 添加了文件命名最佳实践
- 增强了工作空间健康检查以检测带有版本后缀的文件
- 添加了SQL特定的清理工作流程