amanpal3/Dr-SKILLs / .agent/plugins/ralph/skills/dev-browser
dev-browser
FlaggedBrowser automation with persistent page state. Use when users ask to navigate websites, fill forms, take screenshots, extract web data, test web apps, or automate browser workflows. Trigger phrases include "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", "test the website", "log into", or any browser interaction request.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.7 KB |
| bun.lock | other | 46.0 KB |
| package-lock.json | manifest | 90.2 KB |
| package.json | manifest | 718 B |
| references/scraping.md | markdown | 5.2 KB |
| scripts/start-relay.ts | script | 677 B |
| scripts/start-server.ts | script | 3.6 KB |
| server.sh | script | 521 B |
| src/client.ts | script | 14.6 KB |
| src/index.ts | script | 8.6 KB |
| src/relay.ts | script | 21.1 KB |
| src/snapshot/__tests__/snapshot.test.ts | script | 5.6 KB |
| src/snapshot/browser-script.ts | script | 36.9 KB |
| src/snapshot/index.ts | script | 562 B |
| src/snapshot/inject.ts | script | 578 B |
| src/types.ts | script | 726 B |
| tsconfig.json | config | 844 B |
| vitest.config.ts | script | 283 B |
scripts/start-server.ts
View on GitHubimport { serve } from "@/index.js";
import { execSync } from "child_process";
import { mkdirSync, existsSync, readdirSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const tmpDir = join(__dirname, "..", "tmp");
const profileDir = join(__dirname, "..", "profiles");
// Create tmp and profile directories if they don't exist
console.log("Creating tmp directory...");
mkdirSync(tmpDir, { recursive: true });
console.log("Creating profiles directory...");
mkdirSync(profileDir, { recursive: true });
// Install Playwright browsers if not already installed
console.log("Checking Playwright browser installation...");
function findPackageManager(): { name: string; command: string } | null {
const managers = [
{ name: "bun", command: "bunx playwright install chromium" },
{ name: "pnpm", command: "pnpm exec playwright install chromium" },
{ name: "npm", command: "npx playwright install chromium" },
];
for (const manager of managers) {
try {
execSync(`which ${manager.name}`, { stdio: "ignore" });
return manager;
} catch {
// Package manager not found, try next
}
}
return null;
}
function isChromiumInstalled(): boolean {
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
const playwrightCacheDir = join(homeDir, ".cache", "ms-playwright");
if (!existsSync(playwrightCacheDir)) {
return false;
}
// Check for chromium directories (e.g., chromium-1148, chromium_headless_shell-1148)
try {
const entries = readdirSync(playwrightCacheDir);
return entries.some((entry) => entry.startsWith("chromium"));
} catch {
return false;
}
}
try {
if (!isChromiumInstalled()) {
console.log("Playwright Chromium not found. Installing (this may take a minute)...");
const pm = findPackageManager();
if (!pm) {
throw new Error("No package manager found (tried bun, pnpm, npm)");
}
console.log(`Using ${pm.name} to install Playwright...`);
execSync(pm.command, { stdio: "inherit" });
console.log("Chromium installed successfully.");
} else {
console.log("Playwright Chromium already installed.");
}
} catch (error) {
console.error("Failed to install Playwright browsers:", error);
console.log("You may need to run: npx playwright install chromium");
}
// Check if server is already running
console.log("Checking for existing servers...");
try {
const res = await fetch("http://localhost:9222", {
signal: AbortSignal.timeout(1000),
});
if (res.ok) {
console.log("Server already running on port 9222");
process.exit(0);
}
} catch {
// Server not running, continue to start
}
// Clean up stale CDP port if HTTP server isn't running (crash recovery)
// This handles the case where Node crashed but Chrome is still running on 9223
try {
const pid = execSync("lsof -ti:9223", { encoding: "utf-8" }).trim();
if (pid) {
console.log(`Cleaning up stale Chrome process on CDP port 9223 (PID: ${pid})`);
execSync(`kill -9 ${pid}`);
}
} catch {
// No process on CDP port, which is expected
}
console.log("Starting dev browser server...");
const headless = process.env.HEADLESS === "true";
const server = await serve({
port: 9222,
headless,
profileDir,
});
console.log(`Dev browser server started`);
console.log(` WebSocket: ${server.wsEndpoint}`);
console.log(` Tmp directory: ${tmpDir}`);
console.log(` Profile directory: ${profileDir}`);
console.log(`\nReady`);
console.log(`\nPress Ctrl+C to stop`);
// Keep the process running
await new Promise(() => {});
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |