Skip to content

Commit 31df0a9

Browse files
authored
Merge pull request #368 from TencentCloudBase/feature/manage-local-skills-extract
feat(skills): 🧰 add manage-local-skills workflow
2 parents c3ffcae + 6146cf6 commit 31df0a9

22 files changed

Lines changed: 1823 additions & 0 deletions

.agents/skills/manage-local-skills

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../skills/manage-local-skills

.agents/skills/skill-authoring

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../skills/skill-authoring

.claude/skills/manage-local-skills

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.agents/skills/manage-local-skills

.claude/skills/skill-authoring

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.agents/skills/skill-authoring
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.agents/skills/manage-local-skills

.codebuddy/skills/skill-authoring

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.agents/skills/skill-authoring
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
name: manage-local-skills
3+
description: Analyze, standardize, validate, and sync locally maintained skills into agent skill directories with a `skills` CLI-aligned workflow. Use this skill when Codex needs to turn ad-hoc prompt or rules folders into reusable `SKILL.md`-based skills, install or sync one or more local skills from `./skills` into Claude, Cursor, CodeBuddy, Codex, or similar agent directories, or manage local skill path mappings and symlink or copy installation behavior.
4+
---
5+
6+
# Manage Local Skills
7+
8+
Manage locally maintained skills as reusable, standard skill assets.
9+
10+
## What this skill does
11+
12+
Use this skill to:
13+
14+
- classify local sources as standard skills, non-standard skill-like folders, or mixed repositories
15+
- convert non-standard local materials into a standard `SKILL.md`-based structure
16+
- validate standard skill structure before installation
17+
- sync one or more local skills into one or more agent skill directories
18+
- maintain explicit agent and IDE path mappings for local skill installation
19+
20+
## Do not use this skill for
21+
22+
- publishing remote skills registries or package indexes
23+
- cloning skills from remote repositories
24+
- interactive marketplace search
25+
- generic documentation cleanup unrelated to local skill structure
26+
27+
## Workflow
28+
29+
1. Identify whether the user wants analysis only, migration, validation, mapping changes, or installation.
30+
2. If the source is not obviously standard, read `references/source-classification.md` and run `scripts/inspect-source.mjs` first.
31+
3. If migration is needed, read `references/migration-playbook.md` and convert the source into a standard skill folder before installation.
32+
4. Before mounting a skill, read `references/cli-alignment.md` and `references/install-workflow.md` to preserve the canonical-install model.
33+
5. Use `scripts/validate-skill.mjs` before and after installation when structure or path correctness is in doubt.
34+
6. If the target agent is new or unclear, read `references/mapping-extension.md` before adding or changing mappings.
35+
36+
## Common requests
37+
38+
- "Install this local skill into Claude and Cursor."
39+
- "Sync everything under `./skills` to Codex and CodeBuddy."
40+
- "Turn this prompts folder into a reusable skill."
41+
- "Link my local skills into the agent directories for this project."
42+
43+
## Routing
44+
45+
| Task | Read | Script |
46+
| --- | --- | --- |
47+
| Understand how this differs from or aligns with `skills` CLI | `references/cli-alignment.md` | |
48+
| Classify local sources and detect migration candidates | `references/source-classification.md` | `scripts/inspect-source.mjs` |
49+
| Convert non-standard local folders into standard skills | `references/migration-playbook.md` | `scripts/inspect-source.mjs` |
50+
| Install or mount local skills into agent directories | `references/install-workflow.md` | `scripts/install-skill.mjs` |
51+
| Add or update agent mappings | `references/mapping-extension.md` | `scripts/install-skill.mjs` |
52+
| Validate structure or installation results | `references/install-workflow.md` | `scripts/validate-skill.mjs` |
53+
54+
## Operating rules
55+
56+
- Treat `skills` CLI installation semantics as the behavioral baseline for canonical directory layout, scope handling, and symlink fallback.
57+
- Prefer analysis first when the source structure is ambiguous.
58+
- Do not execute arbitrary scripts from the source folder while inspecting it.
59+
- Keep local source directories distinct from canonical install directories.
60+
- Prefer symlinks when supported and safe. Fall back to copy when the user requests it or symlinks fail.
61+
- Make scope explicit: `project` means the current workspace, `global` means the user-level agent directory.
62+
- Ask the user to confirm before writing files, replacing existing installs, changing mappings, or converting a non-standard source into a standard skill.
63+
- If the user asks to sync multiple skills or multiple agents, summarize the planned batch operation before execution and wait for confirmation.
64+
- Call out differences whenever the requested behavior cannot fully match `skills` CLI.
65+
66+
## Quick commands
67+
68+
```bash
69+
node skills/manage-local-skills/scripts/inspect-source.mjs --input <path> --json
70+
node skills/manage-local-skills/scripts/validate-skill.mjs --skill-dir <path>
71+
node skills/manage-local-skills/scripts/install-skill.mjs --source-dir skills --skill <name> --agent cursor --scope project --mode symlink
72+
```
73+
74+
## Minimum self-check
75+
76+
- Is the source clearly classified as `standard`, `nonstandard`, or `mixed`?
77+
- Is the target skill structure valid before installation?
78+
- Is the canonical install path separate from the maintained source directory?
79+
- Is the selected agent mapping explicit and correct for the requested scope?
80+
- If symlink mode is used, is there a defined fallback to copy mode?
81+
- If behavior differs from `skills` CLI, did you state the difference clearly?
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# CLI Alignment
2+
3+
Use this reference when local skill management must behave like the `skills` CLI as closely as possible.
4+
5+
## Behavioral baseline
6+
7+
The local management flow should preserve these `skills` CLI ideas:
8+
9+
1. Keep a canonical installed copy of the skill separate from the maintained source folder.
10+
2. Install from the canonical directory into agent-specific directories.
11+
3. Prefer symlinks for agent-specific installs when supported.
12+
4. Fall back to copy mode when symlinks fail or when the user explicitly requests copying.
13+
5. Distinguish `project` scope from `global` scope.
14+
6. Treat universal `.agents/skills` targets and agent-specific targets with one shared model.
15+
16+
## Canonical directory model
17+
18+
For local management in this skill:
19+
20+
- `project` canonical base: `<cwd>/.agents/skills`
21+
- `global` canonical base: `~/.agents/skills`
22+
23+
The maintained source might be `skills/<skill-name>/`, but installation should copy it into the canonical base first.
24+
25+
That separation matters because it:
26+
27+
- keeps the maintained source independent from install state
28+
- avoids exposing one source folder directly to every agent
29+
- makes overwrite handling and verification more predictable
30+
31+
## Agent target model
32+
33+
After the canonical directory exists:
34+
35+
- universal agents can use the canonical `.agents/skills` path directly
36+
- agent-specific targets should point to the canonical install
37+
- symlink mode should create a target entry that resolves back to the canonical directory
38+
- copy mode should materialize a standalone copy in the target agent directory
39+
40+
## Alignment scope in this skill
41+
42+
This skill intentionally aligns with local installation behavior, not the full CLI surface.
43+
44+
Aligned in the first version:
45+
46+
- canonical install directory
47+
- project and global scope selection
48+
- universal versus agent-specific target handling
49+
- symlink-first installation with copy fallback
50+
- path safety and conflict checks
51+
- the upstream `sanitizeName()` character policy: lowercase, allow `a-z`, `0-9`, `.`, `_`, replace other runs with `-`, trim leading and trailing `.` or `-`, fallback to `unnamed-skill`
52+
- the four IDE mappings used in this repo: Claude, Cursor, CodeBuddy, and Codex
53+
54+
Not covered in the first version:
55+
56+
- remote repository cloning
57+
- interactive TUI prompts
58+
- telemetry, audit, and leaderboard behavior
59+
- lock file restoration and update workflows
60+
61+
## How to reason about differences
62+
63+
If the requested behavior depends on unsupported CLI features, state that clearly and proceed with the local equivalent when possible.
64+
65+
Examples:
66+
67+
- Remote repository install requested: explain that this skill manages local sources and does not clone repositories.
68+
- Interactive selection requested: explain that this skill expects explicit paths, skill names, and target agents.
69+
- Lockfile restore requested: explain that this skill validates and mounts local skills, but does not rehydrate a lockfile workflow.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Install Workflow
2+
3+
Use this reference when mounting a local skill into one or more agent directories.
4+
5+
## Installation model
6+
7+
Treat installation as a two-stage process:
8+
9+
1. Copy the maintained source into a canonical install directory.
10+
2. Expose that canonical install to one or more agent directories.
11+
12+
This keeps maintained sources separate from runtime install state.
13+
14+
## Scope
15+
16+
Use `project` scope when the skill should live under the current workspace.
17+
18+
- canonical base: `<cwd>/.agents/skills`
19+
20+
Use `global` scope when the skill should live under the user environment.
21+
22+
- canonical base: `~/.agents/skills`
23+
24+
Always make scope explicit before writing files.
25+
26+
Before performing a real install, confirm with the user when:
27+
28+
- the operation will write files instead of dry-run only
29+
- multiple skills or multiple agents are involved
30+
- an existing canonical path or target path will be replaced or updated
31+
32+
## Mode
33+
34+
Use `symlink` mode by default when the filesystem supports it and the user does not require physical copies.
35+
36+
Use `copy` mode when:
37+
38+
- the user asks for independent copies
39+
- symlinks are unsupported or unreliable
40+
- a target environment rejects symlinks
41+
42+
If symlink mode fails, report the fallback and switch to copy mode.
43+
44+
## Conflict handling
45+
46+
Before mounting a skill, check whether the canonical path or target path already exists.
47+
48+
Report one of these outcomes clearly:
49+
50+
- `overwrite`: replace the existing target with the new install
51+
- `skip`: leave the existing target untouched
52+
- `replace`: remove and recreate the target path
53+
- `update`: canonical target already exists and will be refreshed from the source
54+
55+
Do not silently replace an existing skill path.
56+
Show the user the conflict summary first, then proceed only after confirmation.
57+
58+
## Dry run
59+
60+
Use dry run when the user wants analysis or confirmation before changing files.
61+
62+
Dry run output should include:
63+
64+
- source skill directory
65+
- canonical target path
66+
- agent target path or paths
67+
- selected scope
68+
- selected mode
69+
- detected conflicts
70+
71+
## Validation after install
72+
73+
After installation:
74+
75+
- verify the canonical path exists
76+
- verify the target path exists
77+
- if symlink mode was used, verify the target resolves to the canonical path
78+
- if copy mode was used, verify that required files such as `SKILL.md` are present
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Mapping Extension
2+
3+
Use this reference when adding or updating supported agent or IDE targets.
4+
5+
## Mapping rule
6+
7+
Keep agent path rules in code, not in prose examples.
8+
9+
Each mapping should define:
10+
11+
- the stable agent key
12+
- the project-scope skill directory
13+
- the global-scope skill directory when supported
14+
- whether the target reuses the canonical `.agents/skills` directory
15+
16+
## Minimum mapping shape
17+
18+
```js
19+
{
20+
key: {
21+
skillsDir: '.agents/skills',
22+
globalSkillsDir: '~/.example/skills'
23+
}
24+
}
25+
```
26+
27+
Treat a mapping as universal when `skillsDir === '.agents/skills'`.
28+
29+
Examples:
30+
31+
- Universal: `cursor`, `codex`
32+
- Agent-specific: `claude`, `claude-code`, `codebuddy`
33+
34+
## How to add a new mapping
35+
36+
1. Confirm the agent's project-level skill path.
37+
2. Confirm whether it supports a global user-level skill path.
38+
3. Add the mapping entry in `scripts/lib/agent-mappings.mjs`.
39+
4. Update tests to cover the new path resolution behavior.
40+
5. Update any reference material if the new target introduces a different install expectation.
41+
42+
## When to reject a mapping
43+
44+
Do not add a mapping when:
45+
46+
- the agent does not have a stable local skill directory model
47+
- the requested path is only speculative
48+
- the path cannot be expressed safely with the current install model
49+
50+
State the limitation clearly instead of guessing.

0 commit comments

Comments
 (0)