Skip to main content

Overview

This guide demonstrates how to build a content writing agent from scratch using Deep Agents. The agent you build will:
  1. Load voice and workflow rules from AGENTS.md and skill folders
  2. Delegate web research to a specialized subagent with web_search
  3. Draft blog or social content following the loaded skill
  4. Generate cover or social images with Gemini and save files under the project directory
The code in this tutorial wires in image generation tools and a filesystem backend so the agent can read and write posts, research notes, and images under the project directory. For the full runnable project, see the content-builder-agent example.

Key concepts

This tutorial covers:

Prerequisites

API keys:
  • Anthropic (Claude) or other provider API key
  • Google (Gemini) for image generation with gemini-2.5-flash-image
  • Tavily for web search (free tier)
  • LangSmith for tracing (optional)
Node.js 18 or later.

Setup

1

Create project directory

2

Install dependencies

Add tsx to run content_writer.ts. The --input-type=module flag applies only to --eval, --print, or stdin, not to a script file path.Install @langchain/anthropic so LangChain can load the default Claude model that createDeepAgent uses.
3

Set API keys

Add configuration files

The example keeps behavior in three kinds of files: memory, skills, and subagent definitions.
1

Add AGENTS.md

Create AGENTS.md in the project root. When you later create the agent and specify this file as part of the memory parameter, it gets loaded this into the system prompt so brand voice and research expectations apply to every run.
To make this agent comply with your own tone, pillars, and formatting rules, update the text in AGENTS.md.
2

Add skills

Create a skills/ directory. Each skill is a folder containing a SKILL.md file with YAML frontmatter (name, description) and instructions for the skill.Create skills/blog-post/SKILL.md and copy the following text into it which contains information on crating long-form posts, optimizing content for SEO, and generating cover images.
Next, create skills/social-media/SKILL.md and copy the following text into it which contains information on drafting social media posts and generating accompanying imagery:
They instruct the agent to call the researcher subagent first, write markdown under blogs/, linkedin/, or tweets/, and call generate_cover or generate_social_image for images.When you later create the agent and specify the skills folder(s), then the frontmatter of the SKILLS.md files from those skill folders get loaded this into the system prompt so the agent can use the skill when a task task matches a skill description.

Build the script

Create content_writer.ts in the project root. The following sections belong in one file, in order.
1

Add tools

The researcher uses Tavily search. Blog and social workflows use the Google Generative AI SDK for image generation.
2

Create the agent

When creating the deep agent with createDeepAgent, pass memory paths, the skills directory, image tools, an inline subagent definition, and a FilesystemBackend rooted at the example directory so paths like ./AGENTS.md and ./skills/ resolve correctly.
3

Add an entry point

Run the agent

The filesystem backend can read, write, and delete files under root_dir. Run only in a dedicated directory and review generated content before publishing.
From the project directory:
Pass a prompt as extra arguments:
With LANGSMITH_API_KEY set, you can inspect runs in LangSmith.

Output

On success, the agent writes artifacts under the project root (the example directory), for example:
Paths follow the skill instructions in SKILL.md.

Full code

Browse the complete content-builder-agent example on GitHub, including the Rich-based streaming UI.

Next steps

  • Edit AGENTS.md to change brand voice and research requirements
  • Add skills under skills/<name>/SKILL.md for new content types
  • Add subagents in subagents.yaml and register tools in load_subagents
  • Read Subagents, Skills, and Customization for deeper configuration