Skip to content

Instantly share code, notes, and snippets.

@nelsondev19
Created January 27, 2026 03:13
Show Gist options
  • Select an option

  • Save nelsondev19/b09b9e0efddaf87bf614c28148a4a71a to your computer and use it in GitHub Desktop.

Select an option

Save nelsondev19/b09b9e0efddaf87bf614c28148a4a71a to your computer and use it in GitHub Desktop.
Code snippet to detect which AI agents are installed
import { access } from "fs/promises";
import { homedir } from "os";
import { join } from "path";
const home = homedir();
const codexHome = process.env.CODEX_HOME?.trim() || join(home, ".codex");
const claudeHome =
process.env.CLAUDE_CONFIG_DIR?.trim() || join(home, ".claude");
// Check if path exists (async)
async function existsAsync(path: string): Promise<boolean> {
try {
await access(path);
return true;
} catch {
return false;
}
}
const agents: [string, () => Promise<boolean>][] = [
["amp", () => existsAsync(join(home, ".config/amp"))],
[
"antigravity",
async () =>
(await existsAsync(join(process.cwd(), ".agent"))) ||
(await existsAsync(join(home, ".gemini/antigravity"))),
],
["claude-code", () => existsAsync(claudeHome)],
["clawdbot", () => existsAsync(join(home, ".clawdbot"))],
["cline", () => existsAsync(join(home, ".cline"))],
[
"codebuddy",
async () =>
(await existsAsync(join(process.cwd(), ".codebuddy"))) ||
(await existsAsync(join(home, ".codebuddy"))),
],
[
"codex",
async () =>
(await existsAsync(codexHome)) || (await existsAsync("/etc/codex")),
],
["command-code", () => existsAsync(join(home, ".commandcode"))],
[
"continue",
async () =>
(await existsAsync(join(process.cwd(), ".continue"))) ||
(await existsAsync(join(home, ".continue"))),
],
["crush", () => existsAsync(join(home, ".config/crush"))],
["cursor", () => existsAsync(join(home, ".cursor"))],
["droid", () => existsAsync(join(home, ".factory"))],
["factory", () => existsAsync(join(home, ".factory"))],
["gemini-cli", () => existsAsync(join(home, ".gemini"))],
[
"github-copilot",
async () =>
(await existsAsync(join(process.cwd(), ".github"))) ||
(await existsAsync(join(home, ".copilot"))),
],
["goose", () => existsAsync(join(home, ".config/goose"))],
["kilo", () => existsAsync(join(home, ".kilocode"))],
["kiro-cli", () => existsAsync(join(home, ".kiro"))],
["mcpjam", () => existsAsync(join(home, ".mcpjam"))],
["mux", () => existsAsync(join(home, ".mux"))],
[
"opencode",
async () =>
(await existsAsync(join(home, ".config/opencode"))) ||
(await existsAsync(join(claudeHome, "skills"))),
],
["openhands", () => existsAsync(join(home, ".openhands"))],
["pi", () => existsAsync(join(home, ".pi/agent"))],
["qoder", () => existsAsync(join(home, ".qoder"))],
["qwen-code", () => existsAsync(join(home, ".qwen"))],
["roo", () => existsAsync(join(home, ".roo"))],
["trae", () => existsAsync(join(home, ".trae"))],
["windsurf", () => existsAsync(join(home, ".codeium/windsurf"))],
["zencoder", () => existsAsync(join(home, ".zencoder"))],
["neovate", () => existsAsync(join(home, ".neovate"))],
];
async function detectInstalledAgents(): Promise<string[]> {
const checks = agents.map(async ([name, fn]) => ((await fn()) ? name : null));
const result = await Promise.all(checks);
return result.filter((v): v is string => Boolean(v));
}
async function main() {
const detected = await detectInstalledAgents();
if (detected.length === 0) {
console.log("No agents detected.");
} else {
console.log("Detected agents:");
detected.forEach((agent) => console.log(`- ${agent}`));
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment