|
| 1 | +# create-langgraph |
| 2 | + |
| 3 | +[](https://www.npmjs.com/package/create-langgraph) |
| 4 | +[](https://opensource.org/licenses/MIT) |
| 5 | + |
| 6 | +The official scaffolding tool for [LangGraph.js](https://langchain-ai.github.io/langgraphjs/) projects. Quickly bootstrap new LangGraph applications from curated templates or generate configuration files for existing projects. |
| 7 | + |
| 8 | +## Quick Start |
| 9 | + |
| 10 | +Create a new LangGraph project with a single command: |
| 11 | + |
| 12 | +```bash |
| 13 | +# Using npm |
| 14 | +npm init langgraph@latest |
| 15 | + |
| 16 | +# Using yarn |
| 17 | +yarn create langgraph |
| 18 | + |
| 19 | +# Using pnpm |
| 20 | +pnpm create langgraph |
| 21 | + |
| 22 | +# Using bun |
| 23 | +bunx create-langgraph |
| 24 | +``` |
| 25 | + |
| 26 | +Follow the interactive prompts to select a template and configure your project. |
| 27 | + |
| 28 | +## Templates |
| 29 | + |
| 30 | +Choose from a variety of production-ready templates: |
| 31 | + |
| 32 | +| Template | Description | |
| 33 | +| ------------------------------------------------------------------------------------ | --------------------------------------------------------------- | |
| 34 | +| [**New LangGraph Project**](https://github.com/langchain-ai/new-langgraphjs-project) | A simple, minimal chatbot with memory | |
| 35 | +| [**ReAct Agent**](https://github.com/langchain-ai/react-agent-js) | A flexible agent that can be extended with many tools | |
| 36 | +| [**Memory Agent**](https://github.com/langchain-ai/memory-agent-js) | A ReAct-style agent with persistent memory across conversations | |
| 37 | +| [**Retrieval Agent**](https://github.com/langchain-ai/retrieval-agent-template-js) | An agent with retrieval-based question-answering | |
| 38 | +| [**Data-enrichment Agent**](https://github.com/langchain-ai/data-enrichment-js) | An agent that performs web searches and organizes findings | |
| 39 | + |
| 40 | +### Using a Specific Template |
| 41 | + |
| 42 | +Skip the interactive prompt by specifying a template directly: |
| 43 | + |
| 44 | +```bash |
| 45 | +npx create-langgraph@latest my-project --template react-agent-js |
| 46 | +``` |
| 47 | + |
| 48 | +Available template IDs: |
| 49 | + |
| 50 | +- `new-langgraph-project-js` |
| 51 | +- `react-agent-js` |
| 52 | +- `memory-agent-js` |
| 53 | +- `retrieval-agent-js` |
| 54 | +- `data-enrichment-js` |
| 55 | + |
| 56 | +## Commands |
| 57 | + |
| 58 | +### `create-langgraph [path]` |
| 59 | + |
| 60 | +Creates a new LangGraph project at the specified path. |
| 61 | + |
| 62 | +```bash |
| 63 | +npx create-langgraph@latest my-awesome-agent |
| 64 | +``` |
| 65 | + |
| 66 | +**Options:** |
| 67 | + |
| 68 | +- `-t, --template <template>` — Use a specific template (skips interactive selection) |
| 69 | + |
| 70 | +**What it does:** |
| 71 | + |
| 72 | +1. Downloads the selected template from GitHub |
| 73 | +2. Extracts it to your target directory |
| 74 | +3. Optionally initializes a Git repository |
| 75 | +4. Provides next steps for getting started |
| 76 | + |
| 77 | +### `create-langgraph config [path]` |
| 78 | + |
| 79 | +Scans your project for LangGraph agents and generates a `langgraph.json` configuration file. |
| 80 | + |
| 81 | +```bash |
| 82 | +# In your project directory |
| 83 | +npx create-langgraph@latest config |
| 84 | + |
| 85 | +# Or specify a path |
| 86 | +npx create-langgraph@latest config ./my-project |
| 87 | +``` |
| 88 | + |
| 89 | +This command is useful when: |
| 90 | + |
| 91 | +- You have an existing project and want to add LangGraph Platform support |
| 92 | +- You've added new agents and need to update your configuration |
| 93 | +- You want to automatically detect all agents in your codebase |
| 94 | + |
| 95 | +## Agent Detection |
| 96 | + |
| 97 | +The `config` command automatically detects LangGraph agents defined using these patterns: |
| 98 | + |
| 99 | +### ESM (ES Modules) |
| 100 | + |
| 101 | +```typescript |
| 102 | +// Using createAgent |
| 103 | +export const agent = createAgent({ model, tools }); |
| 104 | + |
| 105 | +// Using StateGraph |
| 106 | +export const graph = new StateGraph(annotation).compile(); |
| 107 | + |
| 108 | +// Using workflow builder pattern |
| 109 | +export const app = workflow.compile(); |
| 110 | +``` |
| 111 | + |
| 112 | +### CommonJS |
| 113 | + |
| 114 | +```javascript |
| 115 | +// Using module.exports |
| 116 | +module.exports.agent = createAgent({ model, tools }); |
| 117 | +module.exports.graph = workflow.compile(); |
| 118 | + |
| 119 | +// Using exports shorthand |
| 120 | +exports.myAgent = createAgent({ model, tools }); |
| 121 | +``` |
| 122 | + |
| 123 | +### What Gets Detected |
| 124 | + |
| 125 | +The scanner looks for: |
| 126 | + |
| 127 | +- `createAgent()` function calls |
| 128 | +- `new StateGraph(...).compile()` patterns |
| 129 | +- `workflow.compile()` or `builder.compile()` patterns |
| 130 | + |
| 131 | +**Important:** Only **exported** agents are included in the generated configuration. Unexported agents will be listed as warnings so you can add the `export` keyword if needed. |
| 132 | + |
| 133 | +## Generated Configuration |
| 134 | + |
| 135 | +The `config` command generates a `langgraph.json` file like this: |
| 136 | + |
| 137 | +```json |
| 138 | +{ |
| 139 | + "node_version": "20", |
| 140 | + "graphs": { |
| 141 | + "agent": "./src/agent.ts:agent", |
| 142 | + "searchAgent": "./src/search.ts:searchAgent" |
| 143 | + }, |
| 144 | + "env": ".env" |
| 145 | +} |
| 146 | +``` |
| 147 | + |
| 148 | +The configuration includes: |
| 149 | + |
| 150 | +- **node_version** — Detected from your current Node.js version |
| 151 | +- **graphs** — Map of agent names to their file paths and export names |
| 152 | +- **env** — Path to `.env` file (if one exists) |
| 153 | + |
| 154 | +## Project Structure |
| 155 | + |
| 156 | +After scaffolding, your project will have this structure: |
| 157 | + |
| 158 | +```txt |
| 159 | +my-project/ |
| 160 | +├── src/ |
| 161 | +│ └── agent.ts # Your LangGraph agent |
| 162 | +├── langgraph.json # LangGraph configuration |
| 163 | +├── package.json |
| 164 | +├── tsconfig.json |
| 165 | +└── .env.example # Environment variables template |
| 166 | +``` |
| 167 | + |
| 168 | +## Next Steps After Creating a Project |
| 169 | + |
| 170 | +```bash |
| 171 | +# Navigate to your project |
| 172 | +cd my-project |
| 173 | + |
| 174 | +# Install dependencies |
| 175 | +npm install # or yarn, pnpm, bun |
| 176 | + |
| 177 | +# Start the LangGraph development server |
| 178 | +npx @langchain/langgraph-cli@latest dev |
| 179 | +``` |
| 180 | + |
| 181 | +The development server provides: |
| 182 | + |
| 183 | +- A local API server for your agents |
| 184 | +- Hot reloading during development |
| 185 | +- Built-in debugging tools |
| 186 | + |
| 187 | +## Analytics |
| 188 | + |
| 189 | +This CLI collects anonymous usage analytics to help improve the tool. The following information is collected: |
| 190 | + |
| 191 | +- Operating system and version |
| 192 | +- Node.js version |
| 193 | +- CLI version |
| 194 | +- Command executed |
| 195 | + |
| 196 | +**No personal information, project details, or code is ever collected.** |
| 197 | + |
| 198 | +To opt out of analytics, set the environment variable: |
| 199 | + |
| 200 | +```bash |
| 201 | +export LANGGRAPH_CLI_NO_ANALYTICS=1 |
| 202 | +``` |
| 203 | + |
| 204 | +## Requirements |
| 205 | + |
| 206 | +- Node.js 18 or later |
| 207 | +- npm, yarn, pnpm, or bun |
| 208 | + |
| 209 | +## Related Packages |
| 210 | + |
| 211 | +- [@langchain/langgraph](https://www.npmjs.com/package/@langchain/langgraph) — The core LangGraph library |
| 212 | +- [@langchain/langgraph-cli](https://www.npmjs.com/package/@langchain/langgraph-cli) — CLI tools for running LangGraph projects |
| 213 | + |
| 214 | +## License |
| 215 | + |
| 216 | +MIT © [LangChain](https://langchain.com) |
0 commit comments