Codemode runs JavaScript that calls actions. Actions come from plugins, and a plugin becomes available once it has a connection. This page installs codemode, adds two connections, and runs code against them.
Install the command-line interface from npm. This requires Node.js 22.12 or newer, or 20.19 or newer on the Node.js 20 line:
npm install -g @shiftlabs/codemodeVerify the installation:
codemode --versionChange to the folder you want to work in, then create its .codemode folder:
cd /path/to/folder
codemode initcodemode init creates .codemode/config.json and an empty .codemode/plugins/ folder. Codemode reads the nearest .codemode folder at or above the working directory.
A plugin is a set of actions for one service. A connection is the configuration a plugin runs with, usually its credentials.
The bundled hackernews plugin needs no credentials. Add a connection to make it available:
codemode connection add hackernews --plugin hackernewsMost plugins need a key or token. Pass it with --set:
codemode connection add gh --plugin github --set token=$GITHUB_TOKENSee Bundled Plugins for every plugin and the values it needs, and Connections for environment variables and OAuth logins.
Pass JavaScript to codemode exec. Each plugin with a connection is a global, and return produces the result:
codemode exec 'return await hackernews.all.top({ limit: 3 })'One run can call several actions and combine their results:
codemode exec '
const repo = await github.repository.get({ owner: "nodejs", repo: "node" });
const [story] = await hackernews.all.top({ limit: 1 });
return { stars: repo.stargazers_count, top: story.title };
'Actions that create, change, or send something run without asking. Review code before running it against a real account. See Security.
Code can search and inspect the available actions through the actions object:
codemode exec 'return actions.find("create issue")'
codemode exec 'return actions.describe("github.issue.create")'See Run Code for the complete discovery flow, logs, and JSON output.
- Run code to learn the calling conventions and what the runtime provides.
- Write a plugin to add actions for an API that is not bundled.
- Use the SDK to run the same code from an application.
Start with the least powerful mechanism that meets your need:
| Need | Start with |
|---|---|
| Call a service that codemode already supports | A connection for the bundled plugin |
| Add actions for one project | A plugin file in .codemode/plugins/ |
| Add actions for every project on your machine | A plugin file in ~/.codemode/plugins/ |
| Share plugins with other people or projects | A package |
| Run code and manage connections from an application | The SDK |
Remove the command-line interface with npm:
npm uninstall -g @shiftlabs/codemodeThis does not remove ~/.codemode, which holds your plugins, installed packages, and trust decisions, or any project's .codemode folder.