feat: server-side save-skill API for Chrome extension (#66)

* feat: move extension save-skill to server-side API

Chrome Web Store rejected the content script approach since it doesn't
inject on pre-existing tabs. Move webpage-to-skill conversion from
client-side to a server-side API route that uses Turndown + weighted
tag detection, eliminating the need for content scripts entirely.

- Add POST /api/save-skill route with SSRF protection and rate limiting
- Rewrite extension to call API with tab URL instead of injecting scripts
- Remove content script, scripting permission, and turndown dependency
- Add name field validation and YAML-escape source URLs
- Bump extension manifest to v1.18.0

* fix: update privacy policy and store listing for server-side save

Privacy policy previously stated "no external requests" which is now
inaccurate. Updated to clearly disclose that the page URL is sent to
agenstskills.com for processing, what data is NOT sent, and that
nothing is stored server-side.

Store listing updated to match: removed "no server" claims, added
data flow explanation, permissions justifications, and data usage
disclosure section for the Chrome Web Store Privacy tab.

* fix: address Devin and CodeRabbit review findings

- Fix SSRF IPv6 checks blocking legit domains (ffmpeg.org, fdroid.org)
  by requiring colon in fc00:/ff prefixes (Devin)
- Add 5MB response body size limit to prevent OOM on large pages,
  applied to both extractFromUrl and fetchGitHubContent (CodeRabbit)
- Guard response.json() in callSaveApi against non-JSON error pages
  from proxies returning HTML 502/504 (CodeRabbit)
- YAML-escape source URL in buildSelectionSkill to match server-side
  handling of URLs with #, :, or query strings (CodeRabbit)
This commit is contained in:
Rohit Ghumare
2026-02-14 06:00:28 +00:00
committed by GitHub
parent bf5903bf7f
commit 514de86727
13 changed files with 3799 additions and 283 deletions
+3 -1
View File
@@ -21,7 +21,8 @@
"next-themes": "^0.4.6",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"tailwind-merge": "^3.4.0"
"tailwind-merge": "^3.4.0",
"turndown": "^7.2.2"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.1.18",
@@ -29,6 +30,7 @@
"@types/node": "^24.10.2",
"@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3",
"@types/turndown": "^5.0.6",
"postcss": "^8.5.6",
"tailwindcss": "^4.1.18",
"typescript": "^5.9.3"
@@ -0,0 +1,291 @@
import { NextRequest, NextResponse } from 'next/server';
import TurndownService from 'turndown';
const rateLimitMap = new Map<string, { count: number; resetTime: number }>();
const RATE_LIMIT_WINDOW_MS = 60 * 1000;
const RATE_LIMIT_MAX_REQUESTS = 10;
function checkRateLimit(key: string): { allowed: boolean; remaining: number } {
const now = Date.now();
const entry = rateLimitMap.get(key);
if (!entry || now > entry.resetTime) {
rateLimitMap.set(key, { count: 1, resetTime: now + RATE_LIMIT_WINDOW_MS });
return { allowed: true, remaining: RATE_LIMIT_MAX_REQUESTS - 1 };
}
if (entry.count >= RATE_LIMIT_MAX_REQUESTS) {
return { allowed: false, remaining: 0 };
}
entry.count++;
return { allowed: true, remaining: RATE_LIMIT_MAX_REQUESTS - entry.count };
}
const BLOCKED_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1', '0.0.0.0']);
function isAllowedUrl(url: string): boolean {
try {
const parsed = new URL(url);
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return false;
const hostname = parsed.hostname.toLowerCase();
const bare = hostname.replace(/^\[|\]$/g, '');
if (BLOCKED_HOSTS.has(hostname) || BLOCKED_HOSTS.has(bare)) return false;
if (bare.startsWith('::ffff:')) return isAllowedUrl(`http://${bare.slice(7)}`);
if (/^127\./.test(bare) || /^0\./.test(bare)) return false;
if (bare.startsWith('10.') || bare.startsWith('192.168.')) return false;
if (/^172\.(1[6-9]|2\d|3[01])\./.test(bare)) return false;
if (bare.startsWith('169.254.')) return false;
if (bare.startsWith('fe80:') || bare.startsWith('fc00:') || bare.startsWith('fd')) return false;
if (/^(22[4-9]|23\d|24\d|25[0-5])\./.test(bare)) return false;
if (/^ff[0-9a-f]{2}:/.test(bare)) return false;
return true;
} catch {
return false;
}
}
const GITHUB_URL_PATTERN = /^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/blob\/([^/]+)\/(.+)$/;
const GITHUB_RAW_PATTERN = /^https?:\/\/raw\.githubusercontent\.com\//;
const FETCH_TIMEOUT = 30_000;
const TECH_KEYWORDS = new Set([
'react', 'vue', 'angular', 'svelte', 'nextjs', 'nuxt', 'remix',
'typescript', 'javascript', 'python', 'rust', 'go', 'java', 'ruby',
'node', 'deno', 'bun', 'docker', 'kubernetes', 'terraform',
'aws', 'gcp', 'azure', 'vercel', 'netlify', 'cloudflare',
'graphql', 'rest', 'grpc', 'websocket', 'redis', 'postgres',
'mongodb', 'sqlite', 'mysql', 'prisma', 'drizzle',
'tailwind', 'css', 'html', 'sass', 'webpack', 'vite', 'esbuild',
'git', 'ci', 'cd', 'testing', 'security', 'authentication',
'api', 'cli', 'sdk', 'mcp', 'llm', 'ai', 'ml', 'openai', 'anthropic',
]);
const TAG_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;
const turndown = new TurndownService({ headingStyle: 'atx', codeBlockStyle: 'fenced' });
interface ExtractedContent {
title: string;
content: string;
sourceUrl: string;
contentType: string;
language?: string;
}
async function extractFromUrl(url: string): Promise<ExtractedContent> {
if (GITHUB_URL_PATTERN.test(url) || GITHUB_RAW_PATTERN.test(url)) {
return fetchGitHubContent(url);
}
const MAX_BODY_SIZE = 5 * 1024 * 1024;
const response = await fetch(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT) });
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
}
const contentLength = Number(response.headers.get('content-length') || '0');
if (contentLength > MAX_BODY_SIZE) {
throw new Error('Response too large');
}
const contentType = response.headers.get('content-type') ?? '';
const body = await response.text();
if (body.length > MAX_BODY_SIZE) {
throw new Error('Response too large');
}
if (contentType.includes('text/html')) {
const titleMatch = body.match(/<title[^>]*>([^<]+)<\/title>/i);
const title = titleMatch?.[1]?.trim() ?? new URL(url).hostname;
const bodyMatch = body.match(/<body[^>]*>([\s\S]*)<\/body>/i);
const content = turndown.turndown(bodyMatch?.[1] ?? body);
return { title, content, sourceUrl: url, contentType: 'webpage' };
}
const title = new URL(url).pathname.split('/').pop() ?? 'Untitled';
return { title, content: body, sourceUrl: url, contentType: 'text' };
}
const LANG_MAP: Record<string, string> = {
'.ts': 'typescript', '.tsx': 'typescript', '.js': 'javascript', '.jsx': 'javascript',
'.py': 'python', '.rb': 'ruby', '.go': 'go', '.rs': 'rust', '.java': 'java',
'.kt': 'kotlin', '.swift': 'swift', '.sh': 'shell', '.yml': 'yaml', '.yaml': 'yaml',
'.json': 'json', '.md': 'markdown', '.html': 'html', '.css': 'css', '.sql': 'sql',
};
async function fetchGitHubContent(url: string): Promise<ExtractedContent> {
let rawUrl = url;
const match = url.match(GITHUB_URL_PATTERN);
if (match) {
const [, owner, repo, branch, path] = match;
rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${path}`;
}
const MAX_BODY_SIZE = 5 * 1024 * 1024;
const response = await fetch(rawUrl, { signal: AbortSignal.timeout(FETCH_TIMEOUT) });
if (!response.ok) {
throw new Error(`Failed to fetch GitHub content: ${response.status} ${response.statusText}`);
}
const contentLength = Number(response.headers.get('content-length') || '0');
if (contentLength > MAX_BODY_SIZE) {
throw new Error('Response too large');
}
const body = await response.text();
if (body.length > MAX_BODY_SIZE) {
throw new Error('Response too large');
}
const filename = rawUrl.split('/').pop() ?? 'file';
const ext = filename.includes('.') ? '.' + filename.split('.').pop()!.toLowerCase() : '';
const language = LANG_MAP[ext];
const isCode = language !== undefined && language !== 'markdown';
const content = isCode ? `\`\`\`${language}\n${body}\n\`\`\`` : body;
return { title: filename, content, sourceUrl: url, contentType: 'github', language };
}
function addTag(counts: Map<string, number>, tag: string, weight: number): void {
if (TAG_PATTERN.test(tag)) {
counts.set(tag, (counts.get(tag) ?? 0) + weight);
}
}
function detectTags(extracted: ExtractedContent): string[] {
const counts = new Map<string, number>();
try {
const segments = new URL(extracted.sourceUrl).pathname
.split('/').filter(Boolean)
.map((s) => s.toLowerCase().replace(/[^a-z0-9-]/g, ''));
for (const seg of segments) {
if (seg.length >= 2 && seg.length <= 30) {
addTag(counts, seg, 2);
}
}
} catch { /* skip */ }
const headingRe = /^#{1,2}\s+(.+)$/gm;
let m: RegExpExecArray | null;
while ((m = headingRe.exec(extracted.content)) !== null) {
for (const word of m[1].toLowerCase().split(/\s+/)) {
const cleaned = word.replace(/[^a-z0-9-]/g, '');
if (cleaned.length >= 2) {
addTag(counts, cleaned, 2);
}
}
}
const codeBlockRe = /^```(\w+)/gm;
while ((m = codeBlockRe.exec(extracted.content)) !== null) {
const lang = m[1].toLowerCase();
if (lang.length >= 2) {
addTag(counts, lang, 3);
}
}
const lower = extracted.content.toLowerCase();
for (const keyword of TECH_KEYWORDS) {
if (new RegExp(`\\b${keyword}\\b`, 'i').test(lower)) {
addTag(counts, keyword, 1);
}
}
if (extracted.language) {
addTag(counts, extracted.language.toLowerCase(), 3);
}
return Array.from(counts.entries())
.sort((a, b) => b[1] - a[1])
.slice(0, 10)
.map(([tag]) => tag);
}
function slugify(input: string): string {
const slug = input
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '')
.replace(/-{2,}/g, '-');
return slug.slice(0, 64).replace(/-+$/, '') || 'untitled-skill';
}
function yamlEscape(value: string): string {
const singleLine = value.replace(/\r?\n/g, ' ').trim();
if (/[:#{}[\],&*?|>!%@`]/.test(singleLine) || singleLine.startsWith("'") || singleLine.startsWith('"')) {
return `"${singleLine.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
}
return singleLine;
}
export async function POST(request: NextRequest) {
const ip = request.headers.get('x-forwarded-for')?.split(',')[0]?.trim() ?? 'unknown';
const { allowed, remaining } = checkRateLimit(ip);
if (!allowed) {
return NextResponse.json(
{ error: 'Too many requests. Try again in a minute.' },
{ status: 429, headers: { 'X-RateLimit-Remaining': '0', 'Retry-After': '60' } },
);
}
let body: { url?: string; name?: string };
try {
body = await request.json();
} catch {
return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });
}
const { url, name } = body;
if (!url || typeof url !== 'string') {
return NextResponse.json({ error: 'Missing required field: url' }, { status: 400 });
}
if (name !== undefined && typeof name !== 'string') {
return NextResponse.json({ error: 'Field "name" must be a string' }, { status: 400 });
}
if (!isAllowedUrl(url)) {
return NextResponse.json({ error: 'URL not allowed' }, { status: 403 });
}
try {
const extracted = await extractFromUrl(url);
const tags = detectTags(extracted);
const skillName = slugify(name || extracted.title || 'untitled');
const description = extracted.content
.split('\n')
.find((l) => l.trim().length > 0)
?.replace(/^#+\s*/, '')
.trim()
.slice(0, 200) || 'Saved skill';
const savedAt = new Date().toISOString();
const yamlTags = tags.length > 0
? `tags:\n${tags.map((t) => ` - ${t}`).join('\n')}\n`
: '';
const skillMd =
`---\n` +
`name: ${skillName}\n` +
`description: ${yamlEscape(description)}\n` +
yamlTags +
`metadata:\n` +
` source: ${yamlEscape(url)}\n` +
` savedAt: ${savedAt}\n` +
`---\n\n` +
extracted.content + '\n';
return NextResponse.json(
{ name: skillName, skillMd, tags, description },
{ headers: { 'X-RateLimit-Remaining': String(remaining) } },
);
} catch (err) {
const message = err instanceof Error ? err.message : 'Failed to extract content';
return NextResponse.json({ error: message }, { status: 502 });
}
}
+16 -7
View File
@@ -24,21 +24,30 @@
<div class="container">
<a href="/" class="back">&larr; Back to SkillKit</a>
<h1>Privacy Policy</h1>
<p class="updated">Last updated: February 10, 2026</p>
<p class="updated">Last updated: February 14, 2026</p>
<h2>Overview</h2>
<p>SkillKit ("we", "our", "us") is an open-source CLI tool and Chrome extension for managing AI agent skills. We are committed to protecting your privacy. This policy explains what data we collect (or don't) across all SkillKit products.</p>
<h2>Chrome Extension — "SkillKit - Save as Skill"</h2>
<p>The Chrome extension operates entirely within your browser. It does not collect, transmit, or store any personal data externally.</p>
<p>The Chrome extension helps you save webpages as AI agent skill files.</p>
<ul>
<li><strong>No data collection:</strong> We do not collect browsing history, page content, personal information, or any other user data.</li>
<li><strong>No external requests:</strong> The extension makes zero network requests. All processing (HTML to markdown conversion, SKILL.md generation) happens locally in your browser.</li>
<li><strong>What data is sent:</strong> When you click "Save as Skill", the extension sends the URL of the current page to our server at <code>agenstskills.com/api/save-skill</code>. This is required to fetch and convert the webpage content into a skill file.</li>
<li><strong>What data is NOT sent:</strong> We do not send page content, browsing history, personal information, cookies, authentication tokens, or any data beyond the single URL you choose to save.</li>
<li><strong>No data stored on server:</strong> The URL is processed in real time to extract content, generate tags, and build the skill file. No URLs, page content, or user data are stored, logged, or retained on the server after the response is returned.</li>
<li><strong>Selection saves are local:</strong> When you save selected text via the right-click menu, the skill file is built entirely in the browser with no network requests.</li>
<li><strong>No analytics or tracking:</strong> We do not use any analytics, telemetry, or tracking services.</li>
<li><strong>Local storage only:</strong> The Chrome storage API is used solely to store user preferences (e.g., default settings) on your device. This data never leaves your browser.</li>
<li><strong>No user accounts:</strong> No login, API key, or account is required.</li>
<li><strong>Downloads:</strong> Generated skill files are saved to your local filesystem via the Chrome Downloads API. No files are uploaded anywhere.</li>
</ul>
<h2>Permissions Used</h2>
<ul>
<li><strong>activeTab:</strong> Read the URL and title of the tab you are viewing when you click the extension. Only accessed when you actively use the extension.</li>
<li><strong>contextMenus:</strong> Add "Save page as Skill" and "Save selection as Skill" to the right-click menu.</li>
<li><strong>downloads:</strong> Save the generated SKILL.md file to your Downloads folder.</li>
</ul>
<h2>CLI Tool</h2>
<p>The SkillKit CLI runs entirely on your local machine. It does not phone home, collect telemetry, or transmit any data to external servers unless you explicitly use network features (e.g., <code>skillkit install</code> fetches public GitHub repositories).</p>
@@ -49,10 +58,10 @@
<p>The SkillKit website (<a href="https://agenstskills.com">agenstskills.com</a>) is a static site hosted on Vercel. We do not use cookies, analytics trackers, or collect personal information. Vercel may collect standard web server logs (IP address, user agent) as described in their <a href="https://vercel.com/legal/privacy-policy">privacy policy</a>.</p>
<h2>Third-Party Services</h2>
<p>SkillKit does not integrate with any third-party data processors, advertising networks, or analytics services.</p>
<p>The Chrome extension communicates with <code>agenstskills.com</code> (our own server, hosted on Vercel) to process webpage URLs. No third-party data processors, advertising networks, or analytics services are used.</p>
<h2>Data Retention</h2>
<p>We do not retain any user data because we do not collect any user data.</p>
<p>We do not retain any user data. URLs sent to the API are processed in memory and discarded immediately after the response.</p>
<h2>Changes to This Policy</h2>
<p>We may update this privacy policy from time to time. Changes will be posted on this page with an updated revision date.</p>
+1 -4
View File
@@ -9,12 +9,9 @@
"dev": "tsup --watch",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"turndown": "^7.2.2"
},
"dependencies": {},
"devDependencies": {
"@types/chrome": "^0.0.280",
"@types/turndown": "^5.0.6",
"tsup": "^8.3.5",
"typescript": "^5.7.2"
}
+87 -93
View File
@@ -1,13 +1,6 @@
import type { SaveResponse, ErrorResponse, ExtensionMessage } from './types';
const TECH_KEYWORDS = new Set([
'react', 'vue', 'angular', 'svelte', 'next', 'nuxt', 'node', 'deno', 'bun',
'typescript', 'javascript', 'python', 'rust', 'go', 'java', 'kotlin', 'swift',
'docker', 'kubernetes', 'aws', 'gcp', 'azure', 'terraform', 'ansible',
'graphql', 'rest', 'api', 'sql', 'nosql', 'redis', 'postgres', 'mongodb',
'testing', 'ci', 'cd', 'git', 'webpack', 'vite', 'tailwind', 'css',
'ai', 'ml', 'llm', 'mcp', 'agent', 'prompt', 'rag', 'embedding',
]);
const API_URL = 'https://agenstskills.com/api/save-skill';
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
@@ -28,83 +21,107 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
try {
if (info.menuItemId === 'save-page') {
const pageInfo = await chrome.tabs.sendMessage(tab.id, { type: 'GET_PAGE_INFO' });
if (pageInfo?.type === 'PAGE_INFO') {
const { url, title, markdown } = pageInfo.payload;
const result = generateAndDownload({ url, title, content: markdown });
notifyTab(tab.id, result);
const url = tab.url ?? '';
if (!url || url.startsWith('chrome://') || url.startsWith('about:')) {
notifyTab(tab.id, { error: 'Cannot save skills from this page' });
return;
}
const result = await callSaveApi(url);
if (!('error' in result)) {
downloadSkill(result.name, result.skillMd);
}
notifyTab(tab.id, result);
}
if (info.menuItemId === 'save-selection' && info.selectionText) {
const url = tab.url ?? '';
const result = generateAndDownload({ url, title: '', content: info.selectionText });
const result = buildSelectionSkill(info.selectionText, url);
downloadSkill(result.name, result.skillMd);
notifyTab(tab.id, result);
}
} catch {
notifyTab(tab.id, { error: 'Failed to extract page content' });
notifyTab(tab.id, { error: 'Failed to save skill' });
}
});
chrome.runtime.onMessage.addListener(
(message: ExtensionMessage, _sender, sendResponse) => {
if (message.type === 'SAVE_PAGE') {
const { url, title, markdown, name } = message.payload;
sendResponse(generateAndDownload({ url, title, content: markdown, name }));
} else if (message.type === 'SAVE_SELECTION') {
const { text, url, name } = message.payload;
sendResponse(generateAndDownload({ url, title: '', content: text, name }));
const { url, name } = message.payload;
callSaveApi(url, name).then((result) => {
if (!('error' in result)) {
downloadSkill(result.name, result.skillMd);
}
sendResponse(result);
}).catch(() => {
sendResponse({ error: 'Failed to save skill' });
});
return true;
}
if (message.type === 'SAVE_SELECTION') {
const { text, url, name } = message.payload;
const result = buildSelectionSkill(text, url, name);
downloadSkill(result.name, result.skillMd);
sendResponse(result);
}
return false;
},
);
interface GenerateInput {
url: string;
title: string;
content: string;
name?: string;
async function callSaveApi(url: string, name?: string): Promise<SaveResponse | ErrorResponse> {
const response = await fetch(API_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url, name }),
});
let data: Record<string, unknown>;
try {
data = await response.json();
} catch {
return { error: `Server error: ${response.status}` };
}
if (!response.ok) {
return { error: (data.error as string) ?? `Server error: ${response.status}` };
}
return {
name: data.name as string,
filename: `${data.name}/SKILL.md`,
skillMd: data.skillMd as string,
tags: (data.tags as string[]) ?? [],
};
}
function generateAndDownload(input: GenerateInput): SaveResponse | ErrorResponse {
try {
const name = slugify(input.name || input.title || titleFromUrl(input.url));
const tags = detectTags(input.url, input.content);
const description = makeDescription(input.content);
const savedAt = new Date().toISOString();
function buildSelectionSkill(text: string, url: string, name?: string): SaveResponse {
const skillName = slugify(name || 'selection');
const savedAt = new Date().toISOString();
const yamlTags = tags.length > 0
? `tags:\n${tags.map((t) => ` - ${t}`).join('\n')}\n`
: '';
const skillMd =
`---\n` +
`name: ${skillName}\n` +
`description: Selected text saved as skill\n` +
`metadata:\n` +
(url ? ` source: ${yamlEscape(url)}\n` : '') +
` savedAt: ${savedAt}\n` +
`---\n\n` +
text + '\n';
const skillMd =
`---\n` +
`name: ${name}\n` +
`description: ${yamlEscape(description)}\n` +
yamlTags +
`metadata:\n` +
(input.url ? ` source: ${input.url}\n` : '') +
` savedAt: ${savedAt}\n` +
`---\n\n` +
input.content + '\n';
return {
name: skillName,
filename: `${skillName}/SKILL.md`,
skillMd,
tags: [],
};
}
const filename = `${name}/SKILL.md`;
const blob = new Blob([skillMd], { type: 'text/markdown' });
const blobUrl = URL.createObjectURL(blob);
chrome.downloads.download({
url: blobUrl,
filename: `skillkit-skills/${filename}`,
saveAs: false,
}, () => {
URL.revokeObjectURL(blobUrl);
});
return { name, filename, skillMd, tags };
} catch (err) {
return { error: err instanceof Error ? err.message : 'Generation failed' };
function yamlEscape(value: string): string {
const singleLine = value.replace(/\r?\n/g, ' ').trim();
if (/[:#{}[\],&*?|>!%@`]/.test(singleLine) || singleLine.startsWith("'") || singleLine.startsWith('"')) {
return `"${singleLine.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
}
return singleLine;
}
function slugify(input: string): string {
@@ -116,39 +133,16 @@ function slugify(input: string): string {
return slug.slice(0, 64).replace(/-+$/, '') || 'untitled-skill';
}
function titleFromUrl(url: string): string {
try {
const pathname = new URL(url).pathname;
const last = pathname.split('/').filter(Boolean).pop();
return last ?? 'untitled';
} catch {
return 'untitled';
}
}
function makeDescription(content: string): string {
const firstLine = content.split('\n').find((l) => l.trim().length > 0) ?? '';
const cleaned = firstLine.replace(/^#+\s*/, '').trim();
if (cleaned.length > 200) return cleaned.slice(0, 197) + '...';
return cleaned || 'Saved skill';
}
function yamlEscape(value: string): string {
const singleLine = value.replace(/\r?\n/g, ' ').trim();
if (/[:#{}[\],&*?|>!%@`]/.test(singleLine) || singleLine.startsWith("'") || singleLine.startsWith('"')) {
return `"${singleLine.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
}
return singleLine;
}
function detectTags(url: string, content: string): string[] {
const text = `${url} ${content}`.toLowerCase();
const found: string[] = [];
for (const kw of TECH_KEYWORDS) {
if (text.includes(kw)) found.push(kw);
if (found.length >= 10) break;
}
return found;
function downloadSkill(name: string, skillMd: string): void {
const blob = new Blob([skillMd], { type: 'text/markdown' });
const blobUrl = URL.createObjectURL(blob);
chrome.downloads.download({
url: blobUrl,
filename: `skillkit-skills/${name}/SKILL.md`,
saveAs: false,
}, () => {
URL.revokeObjectURL(blobUrl);
});
}
function notifyTab(tabId: number, result: SaveResponse | ErrorResponse): void {
-38
View File
@@ -1,38 +0,0 @@
import TurndownService from 'turndown';
import type { ExtensionMessage, PageContent } from './types';
const turndown = new TurndownService({
headingStyle: 'atx',
codeBlockStyle: 'fenced',
});
turndown.remove(['script', 'style', 'nav', 'footer', 'iframe', 'noscript']);
function extractPageContent(): PageContent {
const selection = window.getSelection()?.toString() ?? '';
const description =
document.querySelector('meta[name="description"]')?.getAttribute('content') ?? '';
const article = document.querySelector('article, main, [role="main"]');
const source = article ?? document.body;
const markdown = turndown.turndown(source.innerHTML);
return {
url: window.location.href,
title: document.title || description || window.location.hostname,
markdown,
selection,
description,
};
}
chrome.runtime.onMessage.addListener(
(message: ExtensionMessage, _sender, sendResponse) => {
if (message.type === 'GET_PAGE_INFO') {
const content = extractPageContent();
const response: ExtensionMessage = { type: 'PAGE_INFO', payload: content };
sendResponse(response);
}
return false;
},
);
+2 -8
View File
@@ -1,9 +1,9 @@
{
"manifest_version": 3,
"name": "SkillKit - Save as Skill",
"version": "1.17.0",
"version": "1.18.0",
"description": "Save any webpage as an AI agent skill — instantly available across 44 agents",
"permissions": ["contextMenus", "activeTab", "storage", "downloads"],
"permissions": ["contextMenus", "activeTab", "downloads"],
"background": {
"service_worker": "background.global.js"
},
@@ -15,12 +15,6 @@
"128": "icons/icon128.png"
}
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.global.js"]
}
],
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
-1
View File
@@ -32,7 +32,6 @@
</div>
<button id="save-btn" class="primary">Save as Skill</button>
<button id="save-selection-btn" class="secondary" style="display:none">Save Selection as Skill</button>
<div id="status" class="status" style="display:none">
<span id="status-icon"></span>
+13 -46
View File
@@ -4,7 +4,6 @@ const pageTitle = document.getElementById('page-title')!;
const pageUrl = document.getElementById('page-url')!;
const skillNameInput = document.getElementById('skill-name') as HTMLInputElement;
const saveBtn = document.getElementById('save-btn')!;
const saveSelectionBtn = document.getElementById('save-selection-btn')!;
const statusEl = document.getElementById('status')!;
const statusIcon = document.getElementById('status-icon')!;
const statusText = document.getElementById('status-text')!;
@@ -12,8 +11,6 @@ const resultEl = document.getElementById('result')!;
const resultPath = document.getElementById('result-path')!;
let currentUrl = '';
let currentSelection = '';
let currentMarkdown = '';
let currentTitle = '';
async function init() {
@@ -25,63 +22,33 @@ async function init() {
currentUrl = tab.url || '';
currentTitle = tab.title || '';
try {
const response = await chrome.tabs.sendMessage(
tab.id,
{ type: 'GET_PAGE_INFO' } satisfies ExtensionMessage,
);
if (response?.type === 'PAGE_INFO') {
currentMarkdown = response.payload.markdown;
currentSelection = response.payload.selection;
currentTitle = response.payload.title || currentTitle;
if (currentSelection) {
saveSelectionBtn.style.display = 'block';
}
}
} catch {
// Content script not loaded (chrome:// pages, etc.)
const isRestricted = !currentUrl || currentUrl.startsWith('chrome://') || currentUrl.startsWith('chrome-extension://') || currentUrl.startsWith('about:');
if (isRestricted) {
saveBtn.setAttribute('disabled', '');
setStatus('error', 'Cannot save skills from this page');
return;
}
}
saveBtn.addEventListener('click', async () => {
if (!currentUrl) return;
await save({
setStatus('saving', 'Saving...');
saveBtn.setAttribute('disabled', '');
const message: ExtensionMessage = {
type: 'SAVE_PAGE',
payload: {
url: currentUrl,
title: currentTitle,
markdown: currentMarkdown,
name: skillNameInput.value.trim() || undefined,
},
});
});
saveSelectionBtn.addEventListener('click', async () => {
if (!currentSelection) return;
await save({
type: 'SAVE_SELECTION',
payload: {
text: currentSelection,
url: currentUrl,
name: skillNameInput.value.trim() || undefined,
},
});
});
function setButtonsDisabled(disabled: boolean): void {
const method = disabled ? 'setAttribute' : 'removeAttribute';
saveBtn[method]('disabled', '');
saveSelectionBtn[method]('disabled', '');
}
async function save(message: ExtensionMessage) {
setStatus('saving', 'Saving...');
setButtonsDisabled(true);
};
const response: SaveResponse | ErrorResponse | undefined =
await chrome.runtime.sendMessage(message);
setButtonsDisabled(false);
saveBtn.removeAttribute('disabled');
if (!response) {
setStatus('error', 'No response from background script');
@@ -98,7 +65,7 @@ async function save(message: ExtensionMessage) {
setStatus('success', `Saved "${response.name}"`);
resultPath.textContent = `Downloads/skillkit-skills/${response.filename}`;
resultEl.style.display = 'block';
}
});
function setStatus(type: 'saving' | 'success' | 'error', text: string) {
statusEl.style.display = 'flex';
+2 -12
View File
@@ -9,16 +9,6 @@ export interface ErrorResponse {
error: string;
}
export interface PageContent {
url: string;
title: string;
markdown: string;
selection: string;
description: string;
}
export type ExtensionMessage =
| { type: 'SAVE_PAGE'; payload: { url: string; title: string; markdown: string; name?: string } }
| { type: 'SAVE_SELECTION'; payload: { text: string; url: string; name?: string } }
| { type: 'GET_PAGE_INFO' }
| { type: 'PAGE_INFO'; payload: PageContent };
| { type: 'SAVE_PAGE'; payload: { url: string; title: string; name?: string } }
| { type: 'SAVE_SELECTION'; payload: { text: string; url: string; name?: string } };
@@ -4,7 +4,7 @@
SkillKit - Save as Skill
## Summary (132 chars max)
Save any webpage as an AI agent skill. One click, works across 44 coding agents. No server needed.
Save any webpage as an AI agent skill file. One click, works across 44 coding agents.
## Description
SkillKit lets you save any webpage as a reusable AI agent skill with one click. The saved SKILL.md file works instantly across 44 coding agents including Claude Code, Cursor, Codex, Gemini CLI, Windsurf, and more.
@@ -14,17 +14,20 @@ How it works:
- Right-click any page and select "Save page as Skill"
- Select text, right-click, and choose "Save selection as Skill"
Everything runs in the browser. No server, no API key, no account needed. Pages are converted to clean markdown with auto-generated YAML frontmatter and smart tags.
When you save a page, the extension sends the page URL to agenstskills.com where it is converted to clean markdown with auto-generated tags and YAML frontmatter. The resulting skill file is downloaded to your computer. No page content, browsing history, or personal data is ever sent — only the URL of the page you choose to save.
Saving selected text works entirely offline with no network requests.
After saving, run `skillkit install <path>` to make the skill available to all your AI coding agents at once.
Features:
- Converts HTML to clean markdown
- Converts HTML to clean markdown via server-side processing
- Auto-generates YAML frontmatter with metadata
- Smart tag detection from 40+ tech keywords
- Smart tag detection from 50+ tech keywords (weighted 5-source analysis)
- GitHub URL support (auto-converts blob URLs to raw content)
- Context menu integration for quick saves
- Works on any webpage
- Zero dependencies on external servers
- No account or API key required
Part of the SkillKit ecosystem: https://agenstskills.com
@@ -40,12 +43,29 @@ https://agenstskills.com
## Support URL
https://github.com/rohitg00/skillkit/issues
## Privacy Policy
This extension does not collect, transmit, or store any user data externally. All processing happens locally in the browser. Saved skills are downloaded to the local filesystem via the Chrome Downloads API.
## Privacy Policy URL
https://agenstskills.com/privacy.html
## Single Purpose
Save webpages as AI agent skill files (SKILL.md) for use with coding AI agents.
## Permissions Justification
- activeTab: Read the URL and title of the current tab when the user clicks the extension icon or context menu. Only accessed on explicit user action.
- contextMenus: Add "Save page as Skill" and "Save selection as Skill" to the right-click context menu.
- downloads: Save the generated SKILL.md file to the user's Downloads folder.
## Data Usage Disclosure (for Chrome Web Store Privacy tab)
- Does the extension use remote code? No
- Does it collect user data? No personal data. The page URL is sent to agenstskills.com when the user clicks save.
- Data type: Website content (URL only, on user action)
- Use: Required for core functionality (converting webpage to skill file)
- Transfer: Sent to agenstskills.com (our own server) over HTTPS
- Not sold to third parties
- Not used for creditworthiness or lending
## Host Permissions
None. The extension uses activeTab which grants temporary access only when the user invokes the extension.
## Assets
- promo-small-440x280.png — Small promo tile
- screenshot-1-1280x800.png — Popup UI showing save flow
-1
View File
@@ -3,7 +3,6 @@ import { defineConfig } from 'tsup';
export default defineConfig({
entry: {
background: 'src/background.ts',
content: 'src/content.ts',
popup: 'src/popup.ts',
},
format: ['iife'],
+3357 -65
View File
File diff suppressed because it is too large Load Diff