Skills: manage and import your own, switch on per chat, search instead of listing

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Sonnet 5.5 committed 2026-11-17 14:28:13 +01:00
1 parent e150de3c93
commit a84a3acaa0
20 files changed
+943 -26

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
import { useState } from "react";
import { patch } from "../api";
import { toast } from "../dialogs";
import { useFetch } from "../hooks";
import { useT } from "../i18n";
import { Spinner } from "./Activity";
import { Icon } from "./Icon";
interface SkillInfo {
name: string;
description: string;
files: string[];
user?: boolean;
}
/** Switch skills on for one chat: their full instructions go into every turn. */
export function ChatSkillsDialog({ sessionId, cwd, active, onClose }: { sessionId: string; cwd: string; active: string[]; onClose: () => void }) {
const t = useT();
const { data } = useFetch<{ skills: SkillInfo[] }>(`/commands?cwd=${encodeURIComponent(cwd)}`);
const [picked, setPicked] = useState<string[]>(active);
const [filter, setFilter] = useState("");
const [busy, setBusy] = useState(false);
const all = data?.skills ?? [];
// Chosen skills first, then the rest.
const shown = all
.filter((s) => !filter.trim() || `${s.name} ${s.description}`.toLowerCase().includes(filter.trim().toLowerCase()))
.sort((a, b) => Number(picked.includes(b.name)) - Number(picked.includes(a.name)) || a.name.localeCompare(b.name));
const toggle = (n: string) => setPicked((p) => (p.includes(n) ? p.filter((x) => x !== n) : [...p, n]));
const save = async () => {
setBusy(true);
try {
await patch(`/sessions/${sessionId}`, { skills: picked });
onClose();
} catch (e: any) {
toast(e.message);
setBusy(false);
}
};
return (
<div className="modal-backdrop" onClick={onClose}>
<div className="modal draft-modal" role="dialog" aria-label={t("skills.chatTitle")} onClick={(e) => e.stopPropagation()}>
<h3>{t("skills.chatTitle")}</h3>
<div className="hint" style={{ marginBottom: 8 }}>
{t("skills.chatHint")}
</div>
{!data ? (
<Spinner />
) : all.length === 0 ? (
<div className="empty">{t("skills.empty")}</div>
) : (
<>
{all.length > 6 && <input autoFocus style={{ width: "100%" }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
<div className="issue-list">
{shown.map((s) => (
<label key={s.name} className="row" style={{ gap: 8, alignItems: "flex-start", padding: "2px 0" }}>
<input type="checkbox" checked={picked.includes(s.name)} onChange={() => toggle(s.name)} />
<span>
<code>{s.name}</code>
{s.files.length > 0 && <span className="hint"> · {t("skills.files", { n: s.files.length })}</span>}
<div className="hint">{s.description}</div>
</span>
</label>
))}
</div>
{picked.length > 4 && <div className="notice">{t("skills.manyActive")}</div>}
</>
)}
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
<button onClick={onClose} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={() => void save()} disabled={busy}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
</button>
</div>
</div>
</div>
);
}
+18
View File
@@ -15,6 +15,7 @@ import { Composer } from "./Composer";
import { ShareDialog } from "./ShareDialog";
import { RenameDialog } from "./RenameDialog";
import { InstructionsDialog } from "./InstructionsDialog";
import { ChatSkillsDialog } from "./ChatSkills";
import { RegenerateButton } from "./Regenerate";
import { WorktreeChip } from "./WorktreeChip";
import { QueueList } from "./QueueList";
@@ -565,6 +566,7 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
// The Telegram switch in the ⋯ menu only matters with a paired bot.
const telegramPaired = useFetch<{ paired: boolean }>("/account/telegram").data?.paired ?? false;
const [editingInstructions, setEditingInstructions] = useState(false);
const [pickingSkills, setPickingSkills] = useState(false);
const [showApprovals, setShowApprovals] = useState(false);
const [planning, setPlanning] = useState(false);
const models = useModels();
@@ -823,6 +825,11 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
<Icon name="edit" /> {t("instructions.chip")}
</button>
)}
{!!session.skills?.length && (
<button className="chip" style={{ border: "none" }} onClick={() => !readOnly && setPickingSkills(true)} title={session.skills.join(", ")}>
<Icon name="scroll" /> {t("skills.chip", { n: session.skills.length })}
</button>
)}
{readOnly && <span className="chip">{t("chat.readOnly")}</span>}
{!readOnly && (
<>
@@ -886,6 +893,16 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
>
<Icon name="edit" /> {t("instructions.title")}
</a>
<a
href="#"
onClick={(e) => {
e.preventDefault();
(e.currentTarget.closest("details") as HTMLDetailsElement).open = false;
setPickingSkills(true);
}}
>
<Icon name="scroll" /> {t("skills.chatTitle")}
</a>
<ColorSwatches value={session.color} onChange={(color) => void update({ color })} />
<IconPicker value={session.icon} color={session.color} onChange={(icon) => void update({ icon })} />
<a href="#" onClick={(e) => (e.preventDefault(), ((e.currentTarget.closest("details") as HTMLDetailsElement).open = false), void planJob())} title={t("job.planHint")}>
@@ -1086,6 +1103,7 @@ export function ChatView({ sessionId, onMenu, onClosePane }: { sessionId: string
)}
</div>
{showApprovals && <ProjectPermissions sessionId={sessionId} cwd={session.cwd} onClose={() => setShowApprovals(false)} />}
{pickingSkills && <ChatSkillsDialog sessionId={sessionId} cwd={session.cwd} active={session.skills ?? []} onClose={() => setPickingSkills(false)} />}
{editingInstructions && <InstructionsDialog sessionId={sessionId} value={session.instructions ?? ""} onClose={() => setEditingInstructions(false)} />}
{editingTitle && <RenameDialog sessionId={sessionId} title={session.title} onClose={() => setEditingTitle(false)} />}
{sharing && <ShareDialog sessionId={sessionId} onClose={() => setSharing(false)} />}
+5 -2
View File
@@ -18,6 +18,7 @@ import { Folders } from "./settings/Folders";
import { Users } from "./settings/Users";
import { Audit } from "./settings/Audit";
import { Tools } from "./settings/Tools";
import { Skills } from "./settings/Skills";
import { confirmDialog, promptDialog, toast } from "../dialogs";
type Json = any;
@@ -1088,8 +1089,8 @@ function Raw({ reload }: { reload: () => void }) {
// --- page -------------------------------------------------------------------
const ADMIN_TABS = ["general", "providers", "agents", "mcp", "permissions", "users", "folders", "tools", "audit", "templates", "modes", "account", "raw"] as const;
const USER_TABS = ["general", "templates", "modes", "account"] as const;
const ADMIN_TABS = ["general", "providers", "agents", "mcp", "permissions", "users", "folders", "tools", "audit", "templates", "modes", "skills", "account", "raw"] as const;
const USER_TABS = ["general", "templates", "modes", "skills", "account"] as const;
const TAB_ICONS: Record<string, string> = {
general: "gear",
providers: "brain",
@@ -1102,6 +1103,7 @@ const TAB_ICONS: Record<string, string> = {
audit: "scroll",
templates: "template",
modes: "sparkle",
skills: "scroll",
account: "user",
raw: "file-text",
};
@@ -1139,6 +1141,7 @@ export function Settings({ tab, onMenu }: { tab?: string; onMenu: () => void })
{active === "account" && <Account />}
{active === "templates" && <Templates />}
{active === "modes" && <PersonalModes />}
{active === "skills" && <Skills />}
{cfg && active === "users" && <Users />}
{cfg && active === "folders" && <Folders />}
{cfg && active === "audit" && <Audit />}
+290
View File
@@ -0,0 +1,290 @@
import { useState } from "react";
import { del, get, post, put } from "../../api";
import { confirmDialog, promptDialog, toast } from "../../dialogs";
import { useFetch } from "../../hooks";
import { useT } from "../../i18n";
import { Icon } from "../Icon";
import { Spinner } from "../Activity";
interface SkillInfo {
name: string;
description: string;
files: string[];
}
interface SkillFile {
path: string;
content: string;
}
const TEMPLATE = `---
name: my-skill
description: When to use this skill, in one or two sentences
---
# Instructions
Describe what the agent should do.
`;
/** The user's own skills: SKILL.md plus further files; created here or imported from GitHub. */
export function Skills() {
const t = useT();
const { data, reload } = useFetch<{ skills: SkillInfo[] }>("/skills");
const [editing, setEditing] = useState<{ name: string; isNew: boolean }>();
const [importing, setImporting] = useState(false);
const [filter, setFilter] = useState("");
const list = (data?.skills ?? []).filter((s) => !filter.trim() || `${s.name} ${s.description}`.toLowerCase().includes(filter.trim().toLowerCase()));
const remove = async (s: SkillInfo) => {
if (!(await confirmDialog({ message: t("skills.confirmDelete", { name: s.name }), danger: true }))) return;
try {
await del(`/skills/${s.name}`);
reload();
} catch (e: any) {
toast(e.message);
}
};
return (
<div className="panel">
<h3>
<Icon name="sparkle" /> {t("skills.title")}
</h3>
<div className="hint" style={{ marginBottom: 8 }}>
{t("skills.hint")}
</div>
<div className="row" style={{ gap: 6, marginBottom: 8 }}>
<button className="primary" onClick={() => setEditing({ name: "", isNew: true })}>
<Icon name="plus" /> {t("skills.new")}
</button>
<button onClick={() => setImporting(true)}>
<Icon name="git" /> {t("skills.import")}
</button>
<span className="spacer" />
{(data?.skills.length ?? 0) > 8 && <input placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />}
</div>
{!data ? (
<Spinner />
) : list.length === 0 ? (
<div className="empty">{t("skills.empty")}</div>
) : (
list.map((s) => (
<div key={s.name} className="row" style={{ gap: 8, padding: "6px 0", borderBottom: "1px solid var(--border)" }}>
<div style={{ flex: 1, minWidth: 0 }}>
<code>{s.name}</code>
{s.files.length > 0 && <span className="chip" style={{ marginLeft: 6 }}>{t("skills.files", { n: s.files.length })}</span>}
<div className="hint" style={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
{s.description}
</div>
</div>
<button className="small" onClick={() => setEditing({ name: s.name, isNew: false })}>
<Icon name="edit" /> {t("common.edit")}
</button>
<button className="small danger" onClick={() => void remove(s)} aria-label={t("common.delete")}>
<Icon name="trash" />
</button>
</div>
))
)}
{editing && (
<SkillEditor
name={editing.name}
isNew={editing.isNew}
onClose={(saved) => {
setEditing(undefined);
if (saved) reload();
}}
/>
)}
{importing && (
<ImportDialog
onClose={(done) => {
setImporting(false);
if (done) reload();
}}
/>
)}
</div>
);
}
function SkillEditor({ name: initial, isNew, onClose }: { name: string; isNew: boolean; onClose: (saved: boolean) => void }) {
const t = useT();
const [name, setName] = useState(initial);
const [files, setFiles] = useState<SkillFile[]>(isNew ? [{ path: "SKILL.md", content: TEMPLATE }] : []);
const [loaded, setLoaded] = useState(isNew);
const [current, setCurrent] = useState("SKILL.md");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string>();
useState(() => {
if (!isNew)
get<{ files: SkillFile[] }>(`/skills/${initial}`)
.then((d) => (setFiles(d.files), setLoaded(true)))
.catch((e) => (setError(e.message), setLoaded(true)));
});
const file = files.find((f) => f.path === current) ?? files[0];
const setContent = (content: string) => setFiles(files.map((f) => (f.path === file?.path ? { ...f, content } : f)));
const addFile = async () => {
const p = await promptDialog({ message: t("skills.addFile"), placeholder: "references/guide.md", confirmLabel: t("common.add") });
const path = p?.trim().replace(/^\/+/, "");
if (!path) return;
if (files.some((f) => f.path === path)) return setCurrent(path);
setFiles([...files, { path, content: "" }]);
setCurrent(path);
};
const removeFile = () => {
if (!file || file.path === "SKILL.md") return;
setFiles(files.filter((f) => f.path !== file.path));
setCurrent("SKILL.md");
};
const save = async () => {
setBusy(true);
setError(undefined);
try {
await put(`/skills/${name.trim()}`, { files });
onClose(true);
} catch (e: any) {
setError(e.message);
setBusy(false);
}
};
return (
<div className="modal-backdrop">
<div className="modal draft-modal" role="dialog" aria-label={t("skills.edit")}>
<h3>{isNew ? t("skills.new") : t("skills.edit")}</h3>
{!loaded ? (
<Spinner />
) : (
<>
<label style={{ display: "block", marginBottom: 8 }}>
<span className="hint">{t("skills.name")}</span>
<input className="mono" style={{ width: "100%" }} value={name} disabled={!isNew} placeholder="frontend" onChange={(e) => setName(e.target.value.toLowerCase().replace(/[^a-z0-9_-]/g, "-"))} />
</label>
<div className="row" style={{ gap: 4, flexWrap: "wrap", marginBottom: 6 }}>
{files.map((f) => (
<button key={f.path} className={`small ${f.path === file?.path ? "primary" : ""}`} onClick={() => setCurrent(f.path)}>
{f.path}
</button>
))}
<button className="small ghost" onClick={() => void addFile()}>
<Icon name="plus" /> {t("skills.file")}
</button>
{file && file.path !== "SKILL.md" && (
<button className="small danger" onClick={removeFile} aria-label={t("common.delete")}>
<Icon name="trash" />
</button>
)}
</div>
<textarea className="mono" rows={18} style={{ width: "100%" }} value={file?.content ?? ""} onChange={(e) => setContent(e.target.value)} spellCheck={false} />
<div className="hint">{t("skills.fileHint")}</div>
</>
)}
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
<button onClick={() => onClose(false)} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={() => void save()} disabled={busy || !loaded || !name.trim() || !files.some((f) => f.path === "SKILL.md")}>
{busy ? <Spinner small /> : <Icon name="check" />} {t("common.save")}
</button>
</div>
</div>
</div>
);
}
interface Found {
path: string;
name: string;
files: number;
}
function ImportDialog({ onClose }: { onClose: (done: boolean) => void }) {
const t = useT();
const [url, setUrl] = useState("");
const [found, setFound] = useState<Found[]>();
const [picked, setPicked] = useState<Set<string>>(new Set());
const [filter, setFilter] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string>();
const scan = async () => {
setBusy(true);
setError(undefined);
try {
const r = await post<{ skills: Found[] }>("/skills/github/scan", { url: url.trim() });
setFound(r.skills);
setPicked(new Set());
if (r.skills.length === 0) setError(t("skills.noneFound"));
} catch (e: any) {
setError(e.message);
}
setBusy(false);
};
const shown = (found ?? []).filter((s) => !filter.trim() || s.path.toLowerCase().includes(filter.trim().toLowerCase()));
const toggle = (p: string) => setPicked((s) => (s.has(p) ? new Set([...s].filter((x) => x !== p)) : new Set(s).add(p)));
const run = async () => {
setBusy(true);
setError(undefined);
try {
const r = await post<{ saved: unknown[]; skipped: { path: string; why: string }[] }>("/skills/github/import", { url: url.trim(), paths: [...picked] });
toast(t("skills.imported", { n: r.saved.length }) + (r.skipped.length ? ` (${r.skipped.length} ${t("skills.skipped")})` : ""), "success");
onClose(true);
} catch (e: any) {
setError(e.message);
setBusy(false);
}
};
return (
<div className="modal-backdrop">
<div className="modal draft-modal" role="dialog" aria-label={t("skills.import")}>
<h3>{t("skills.import")}</h3>
<div className="hint" style={{ marginBottom: 8 }}>
{t("skills.importHint")}
</div>
<div className="row" style={{ gap: 6 }}>
<input className="mono" style={{ flex: 1 }} value={url} placeholder="https://github.com/owner/repo/tree/main/skills" onChange={(e) => setUrl(e.target.value)} onKeyDown={(e) => e.key === "Enter" && url.trim() && !busy && void scan()} />
<button onClick={() => void scan()} disabled={busy || !url.trim()}>
{busy && !found ? <Spinner small /> : <Icon name="search" />} {t("skills.scan")}
</button>
</div>
{found && found.length > 0 && (
<>
<div className="row" style={{ gap: 6, margin: "8px 0" }}>
<input style={{ flex: 1 }} placeholder={t("skills.filter")} value={filter} onChange={(e) => setFilter(e.target.value)} />
<button className="small" onClick={() => setPicked(new Set([...picked, ...shown.map((s) => s.path)]))}>
{t("skills.selectShown", { n: shown.length })}
</button>
<button className="small ghost" onClick={() => setPicked(new Set())}>
{t("skills.selectNone")}
</button>
</div>
<div className="issue-list">
{shown.map((s) => (
<label key={s.path} className="row" style={{ gap: 8, padding: "2px 0" }}>
<input type="checkbox" checked={picked.has(s.path)} onChange={() => toggle(s.path)} />
<span>
<code>{s.name}</code> <span className="hint">{s.path} · {t("skills.files", { n: s.files })}</span>
</span>
</label>
))}
</div>
</>
)}
{error && <div className="notice err">{error}</div>}
<div className="row" style={{ marginTop: 10, justifyContent: "flex-end", gap: 6 }}>
<button onClick={() => onClose(false)} disabled={busy}>
{t("common.cancel")}
</button>
<button className="primary" onClick={() => void run()} disabled={busy || picked.size === 0}>
{busy && found ? <Spinner small /> : <Icon name="check" />} {t("skills.importN", { n: picked.size })}
</button>
</div>
</div>
</div>
);
}
+26
View File
@@ -774,6 +774,32 @@ export const de: Messages = {
"instructions.hint": "Gelten für jede Nachricht in diesem Chat, zusätzlich zum Modus – z. B. Sprache, Ton, Regeln oder der Teil des Projekts, um den es geht.",
"instructions.placeholder": "z. B. Antworte immer auf Englisch. Ändere nur Dateien unter api/. Frag, bevor du Abhängigkeiten hinzufügst.",
"instructions.clear": "Entfernen",
"settings.tab.skills": "Skills",
"skills.title": "Skills",
"skills.hint": "Ein Skill ist ein Ordner mit SKILL.md (Anweisungen) und weiteren Dateien. Skills schaltest du pro Chat ein (Menü ⋯ → Skills); ihre Anweisungen gelten dann in jeder Runde, alle anderen kosten keinen Kontext. Agenten können außerdem alle Skills per Stichwort suchen und bei Bedarf laden.",
"skills.new": "Neuer Skill",
"skills.edit": "Skill bearbeiten",
"skills.import": "Von GitHub importieren",
"skills.importHint": "URL eines Repositorys oder eines Ordners darin einfügen. Jeder Ordner mit SKILL.md wird angeboten; die Textdateien des Skills werden mit importiert. Bei großen Repositorys die URL auf einen Ordner eingrenzen (…/tree/main/engineering).",
"skills.scan": "Suchen",
"skills.noneFound": "Unter dieser Adresse wurde keine SKILL.md gefunden.",
"skills.selectShown": "Angezeigte wählen ({n})",
"skills.selectNone": "Keine wählen",
"skills.importN": "{n} importieren",
"skills.imported": "{n} Skills importiert",
"skills.skipped": "übersprungen",
"skills.filter": "Filtern…",
"skills.empty": "Noch keine Skills.",
"skills.files": "{n} Dateien",
"skills.name": "Name (Ordner, Kleinbuchstaben)",
"skills.file": "Datei",
"skills.addFile": "Pfad der neuen Datei",
"skills.fileHint": "SKILL.md beginnt mit einem Kopfblock (name, description); die Beschreibung sagt dem Agenten, wann der Skill passt.",
"skills.confirmDelete": "Skill {name} löschen?",
"skills.chatTitle": "Skills für diesen Chat",
"skills.chatHint": "Eingeschaltete Skills gelten für jede Nachricht dieses Chats. Schalte nur ein, was du brauchst – jeder belegt Kontext.",
"skills.manyActive": "Viele aktive Skills belegen viel Kontext.",
"skills.chip": "{n} Skills",
"instructions.chip": "Anweisungen",
"chat.compacted": "Unterhaltung komprimiert – Zusammenfassung",
"chat.context": "Kontext",
+26
View File
@@ -773,6 +773,32 @@ export const en = {
"instructions.hint": "Apply to every message in this chat, in addition to the mode – e.g. language, tone, rules, the part of the project to work on.",
"instructions.placeholder": "e.g. Always answer in English. Only change files under api/. Ask before adding dependencies.",
"instructions.clear": "Remove",
"settings.tab.skills": "Skills",
"skills.title": "Skills",
"skills.hint": "A skill is a folder with SKILL.md (instructions) and further files. Switch skills on per chat (menu ⋯ → Skills) so their instructions are used in every turn; the others cost no context. Agents can also search all skills by keyword and load one when needed.",
"skills.new": "New skill",
"skills.edit": "Edit skill",
"skills.import": "Import from GitHub",
"skills.importHint": "Paste the URL of a repository or of a folder in it. Every folder with a SKILL.md is offered; text files of the skill are imported with it. For large repositories, narrow the URL to a folder (…/tree/main/engineering).",
"skills.scan": "Search",
"skills.noneFound": "No SKILL.md found at this address.",
"skills.selectShown": "Select shown ({n})",
"skills.selectNone": "Select none",
"skills.importN": "Import {n}",
"skills.imported": "{n} skills imported",
"skills.skipped": "skipped",
"skills.filter": "Filter…",
"skills.empty": "No skills yet.",
"skills.files": "{n} files",
"skills.name": "Name (folder, lowercase)",
"skills.file": "File",
"skills.addFile": "Path of the new file",
"skills.fileHint": "SKILL.md starts with a front matter block (name, description); the description tells the agent when to use the skill.",
"skills.confirmDelete": "Delete the skill {name}?",
"skills.chatTitle": "Skills for this chat",
"skills.chatHint": "Switched-on skills are part of every message of this chat. Switch on only what you need – each one uses context.",
"skills.manyActive": "Many active skills use a lot of context.",
"skills.chip": "{n} skills",
"instructions.chip": "Instructions",
"chat.compacted": "Conversation compacted – summary",
"chat.context": "Context",
+2
View File
@@ -82,6 +82,8 @@ export interface Session {
folder?: string | null;
/** Instructions for this chat (added to the system prompt). */
instructions?: string;
/** Skills switched on for this chat. */
skills?: string[];
/** Approvals and questions of this chat are not sent to Telegram. */
telegram_quiet?: boolean;
}
+4
View File
@@ -3,6 +3,10 @@
* under "unreleased"; scripts/release.sh renames the key to the release version.
*/
export const WHATS_NEW: Record<string, { en: string[]; de: string[] }> = {
unreleased: {
en: ["Skills: create or import them from GitHub (Settings → Skills) and switch them on per chat; large libraries do not fill the context"],
de: ["Skills: selbst anlegen oder von GitHub importieren (Einstellungen → Skills) und pro Chat einschalten; große Bibliotheken füllen den Kontext nicht"],
},
"202611-00055": {
en: ["Fixed: cloning a repository for a new project no longer ends up in the factory area"],
de: ["Behoben: Klonen eines Repositorys für ein neues Projekt landet nicht mehr in der Factory-Ablage"],