From langchain-plugin
Initializes a new LangChain TypeScript project with Bun/NPM package init, core dependencies like @langchain/core and @langchain/openai, tsconfig.json, example ReAct agent, .env.example, and scripts.
npx claudepluginhub laurigates/claude-plugins --plugin langchain-pluginThis skill is limited to using the following tools:
Initialize a new LangChain TypeScript project with optimal configuration for building AI agents.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Initialize a new LangChain TypeScript project with optimal configuration for building AI agents.
Detect the environment:
node --version - Node.js versionwhich bun - Check if Bun is available| Parameter | Description | Default |
|---|---|---|
project-name | Name of the project directory | Required |
mkdir -p $1 && cd $1
If Bun is available:
bun init -y
Otherwise:
npm init -y
Core packages:
# Package manager: bun or npm
bun add langchain @langchain/core @langchain/langgraph
bun add @langchain/openai # Default model provider
# Dev dependencies
bun add -d typescript @types/node tsx
Create tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"outDir": "dist",
"declaration": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
mkdir -p src
Create src/agent.ts:
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { tool } from "@langchain/core/tools";
import { z } from "zod";
// Example tool
const greetTool = tool(
async ({ name }) => `Hello, ${name}!`,
{
name: "greet",
description: "Greet someone by name",
schema: z.object({
name: z.string().describe("The name to greet"),
}),
}
);
// Create the agent
const model = new ChatOpenAI({
model: "gpt-4o",
temperature: 0,
});
export const agent = createReactAgent({
llm: model,
tools: [greetTool],
});
// Run if executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
const result = await agent.invoke({
messages: [{ role: "user", content: "Say hello to Claude" }],
});
console.log(result.messages[result.messages.length - 1].content);
}
Create .env.example:
# OpenAI (default)
OPENAI_API_KEY=sk-...
# Optional: Anthropic
# ANTHROPIC_API_KEY=sk-ant-...
# Optional: LangSmith tracing
# LANGCHAIN_TRACING_V2=true
# LANGCHAIN_API_KEY=ls__...
# LANGCHAIN_PROJECT=my-project
Add to package.json:
{
"scripts": {
"dev": "tsx watch src/agent.ts",
"start": "tsx src/agent.ts",
"build": "tsc",
"typecheck": "tsc --noEmit"
}
}
node_modules/
dist/
.env
*.log
Display success message with next steps:
.env.example to .env and add API keybun dev or npm run dev to startSuggest installing additional model providers if needed:
@langchain/anthropic for Claude@langchain/google-genai for Gemini