Skip to content

feat(skills): create, edit, and delete user and repo skills#2605

Merged
k11kirky merged 2 commits into
mainfrom
posthog-code/skills-02-crud
Jun 12, 2026
Merged

feat(skills): create, edit, and delete user and repo skills#2605
k11kirky merged 2 commits into
mainfrom
posthog-code/skills-02-crud

Conversation

@k11kirky

@k11kirky k11kirky commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Users had no way to create, edit, or delete skills from the UI — the skills panel was read-only. This adds full CRUD support for skills, including creating new skills, editing the manifest and companion files, renaming/deleting files within a skill, and deleting or renaming entire skills.

Changes

Backend (workspace-server)

  • Added createSkill, saveSkillManifest, saveSkillFile, renameSkillFile, deleteSkillFile, deleteSkill, and renameSkill methods to SkillsService.
  • All mutations are guarded by resolveWritableSkillDir, which enforces that the target skill lives directly under a writable root (~/.claude/skills or a workspace folder's .claude/skills). Bundled/plugin skills are rejected server-side.
  • Added validateSkillDirName (lowercase letters, numbers, dots, dashes, underscores; max 64 chars) and resolveSkillFilePath (prevents path traversal out of the skill directory) as shared helpers.
  • Added write-skill-frontmatter.ts with serializeSkillMarkdown, which serializes name/description/body back to a valid SKILL.md. Scalars fall back from plain → double-quoted → YAML literal block to handle colons, quotes, backslashes, and multi-line values.
  • Fixed a bug in collectIndentedLines in parse-skill-frontmatter.ts where blank lines inside a multi-line YAML value were being dropped instead of preserved.
  • Extended schemas.ts with Zod schemas and TypeScript types for all new operations.

Host router (host-router)

  • Exposed create, saveManifest, saveFile, renameFile, deleteFile, delete, and rename tRPC mutations on the skillsRouter.

UI (ui)

  • useSkillMutations.ts — new hooks (useCreateSkill, useSaveSkillManifest, useSaveSkillFile, useRenameSkillFile, useDeleteSkillFile, useDeleteSkill) that each invalidate all skills queries on success.
  • NewSkillDialog.tsx — dialog for creating a skill with a name and a scope selector (user skills or a specific open repository).
  • SkillCodeEditor.tsx — uncontrolled CodeMirror wrapper that reports document changes via onDocChanged.
  • SkillManifestEditor.tsx — edit mode for SKILL.md: a small form for name/description frontmatter fields plus a CodeMirror body editor.
  • SkillFileEditor.tsx — edit mode for companion files inside a skill directory.
  • SkillDetailPanel.tsx — added edit, add-file, delete-skill toolbar buttons (visible only for editable skills), wired up SkillManifestEditor and SkillFileEditor for the active file, and added dialogs for adding a file, renaming a file, confirming file deletion, and confirming skill deletion.
  • SkillFileTree.tsx — added optional onRenameFile/onDeleteFile callbacks; when present, non-SKILL.md file rows show inline rename and delete icon buttons.
  • SkillsView.tsx — added a "New skill" button next to the search field that opens NewSkillDialog and selects the newly created skill.

How did you test this?

  • Added unit tests in skills.test.ts covering createSkill (happy path, invalid names, non-open repo, duplicate names), the write-path guard (bundled skills, arbitrary directories, traversal attacks, file-path escapes), and all mutation methods (manifest round-trip, companion file lifecycle, SKILL.md protection, full skill delete, skill rename).
  • Added unit tests in write-skill-frontmatter.test.ts covering round-trip fidelity for plain values, empty descriptions, colons, special leading characters, double quotes, backslashes, multi-line descriptions, multi-paragraph descriptions, and body sections that contain fake frontmatter fences.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

React Doctor could not complete this scan.

No React dependency found in /tmp/react-doctor-baseline-dcJ4ur/package.json. Add "react" to dependencies (or peerDependencies) and re-run.

Reviewed by React Doctor for commit fc872b6.

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 3 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 3
packages/ui/src/features/skills/SkillDetailPanel.tsx:166
**Edit button enabled while body content is unavailable**

When the `SKILL.md` fetch has settled (e.g. a query error) `isLoading` is `false` but `fileContent` is still `null`, so `body` is `null`. Clicking "Edit" opens `SkillManifestEditor` with `initialBody=""`, and saving immediately overwrites whatever the real body contained with an empty string.

```suggestion
                    disabled={isLoading || (isSkillMd && !fileContent)}
```

### Issue 2 of 3
packages/ui/src/features/skills/NewSkillDialog.tsx:68
**Hint text omits dots and underscores that the validator allows**

`SKILL_DIR_NAME_PATTERN` (`/^[a-z0-9][a-z0-9._-]*$/`) accepts dots and underscores, and the server error message even mentions them explicitly. A user who types `my_skill` will be surprised if the hint told them only dashes were allowed.

```suggestion
              Lowercase letters, numbers, dashes, dots, and underscores
```

### Issue 3 of 3
packages/ui/src/features/skills/useSkillMutations.ts:59
**`useRenameSkill` hook missing — router endpoint is unreachable from the UI**

`skills.ts` implements `renameSkill` and the tRPC router exposes a `rename` procedure, but there is no corresponding hook here and no UI that calls it. If this is intentional (planned for a follow-up), consider either removing the router endpoint from this PR to keep the surface consistent, or adding the hook now so the feature is at least reachable.

Reviews (1): Last reviewed commit: "feat(skills): create, edit, and delete u..." | Re-trigger Greptile

Comment thread packages/ui/src/features/skills/SkillDetailPanel.tsx Outdated
Comment thread packages/ui/src/features/skills/NewSkillDialog.tsx Outdated
Comment thread packages/ui/src/features/skills/useSkillMutations.ts
@k11kirky k11kirky marked this pull request as ready for review June 11, 2026 13:53
@k11kirky k11kirky force-pushed the posthog-code/skills-02-crud branch from 0b5ff98 to 34baff5 Compare June 12, 2026 07:50
@k11kirky k11kirky force-pushed the posthog-code/skills-01-full-rendering branch from d3d7209 to abb385b Compare June 12, 2026 08:19
@k11kirky k11kirky force-pushed the posthog-code/skills-02-crud branch from 34baff5 to 83a4081 Compare June 12, 2026 08:19

k11kirky commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jun 12, 11:31 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 12, 11:32 AM UTC: Graphite couldn't merge this PR because it had merge conflicts.
  • Jun 12, 11:54 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 12, 11:54 AM UTC: @k11kirky merged this pull request with Graphite.

@k11kirky k11kirky changed the base branch from posthog-code/skills-01-full-rendering to graphite-base/2605 June 12, 2026 11:31
@k11kirky k11kirky changed the base branch from graphite-base/2605 to main June 12, 2026 11:31
k11kirky added 2 commits June 12, 2026 12:37
- SkillsService mutations: createSkill (scaffolds directory + templated
  SKILL.md), saveSkillManifest (frontmatter writer + body),
  saveSkillFile, renameSkillFile, deleteSkillFile, deleteSkill,
  renameSkill. Every mutation resolves its target against the writable
  roots (~/.claude/skills and each workspace folder's .claude/skills);
  bundled and plugin-marketplace paths are rejected server-side.
  SKILL.md itself cannot be renamed or deleted.
- serializeSkillMarkdown writes frontmatter that round-trips through
  parseSkillFrontmatter and stays valid YAML (plain -> quoted -> literal
  block as values get more hostile). The parser now tolerates blank
  lines inside block scalars so multi-paragraph descriptions survive.
- host-router skills.* mutation routes as one-line forwards.
- UI: "New skill" button with scope picker (Your skills / repository),
  edit mode in the detail panel (form for frontmatter name/description,
  CodeMirror for the body), add/rename/delete companion files, and
  delete-skill confirmation. Non-editable sources show no affordances.
- Unit tests cover the write-path guard directly (bundled paths,
  arbitrary dirs, traversal), name validation, SKILL.md protection, and
  the frontmatter round-trip.

Generated-By: PostHog Code
Task-Id: f4e84f1a-19c9-490c-9b98-47787a7dddcf
Review feedback on #2605: disable Edit until file content has actually
loaded (prevents wiping SKILL.md with an empty body after a failed
fetch), mention dots and underscores in the name hint, and drop the
unreachable skills.rename endpoint until there is UI for it.

Generated-By: PostHog Code
Task-Id: f4e84f1a-19c9-490c-9b98-47787a7dddcf
@k11kirky k11kirky force-pushed the posthog-code/skills-02-crud branch from 83a4081 to fc872b6 Compare June 12, 2026 11:43
@k11kirky k11kirky merged commit 3676c2c into main Jun 12, 2026
24 checks passed
@k11kirky k11kirky deleted the posthog-code/skills-02-crud branch June 12, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants