Run Claude Code, Gemini CLI, and Codex headlessly through one Node API.
npm install headless-agentsBuild the package before local use if you are working from source:
npm run buildimport { runAgent } from 'headless-agents';
const result = await runAgent({
model: 'claude-sonnet-4-6',
prompt: 'Reply with exactly OK',
workdir: '/absolute/path/to/project',
});
console.log(result.stdout);If this package is published to npm:
import { runAgent } from 'headless-agents';If your main project installs directly from GitHub:
{
"dependencies": {
"headless-agents": "git+https://github.com/hjyeo30/headless-agents.git"
}
}Then in the main project:
import { runAgent } from 'headless-agents';For public npm publishing, an unscoped package name like headless-agents can be used if the name is available.
For private npm publishing, use a scoped package name such as:
{
"name": "@your-scope/headless-agents"
}Then publish from the package root:
npm publishIf you want a scoped package to be public instead, use:
npm publish --access publicIf your main project uses a local checkout:
{
"dependencies": {
"headless-agents": "file:../headless-agents"
}
}Then in the main project:
import { runAgent } from 'headless-agents';- Claude supports
--output-format json - Gemini supports
--output-format json - Codex does not use Claude-style
--output-format json