Initialize a project
agentflow init scaffolds the minimum files needed to run an agent behind the API: a configuration file, a graph module, and optional project structure files.
Prerequisites
You need AgentFlow CLI and Python 3.11 or later.
pip install 10xscale-agentflow-cli
python --version # Verify Python 3.11+
If you want to use the starter agent with Gemini, also install the client:
pip install google-generativeai
Create a project directory
Create and navigate to your agent project directory:
mkdir my-agent-project
cd my-agent-project
python -m venv venv
source venv/bin/activate # On Windows: venv\\Scripts\\activate
Run init
Initialize the project scaffolding:
agentflow init
This creates:
agentflow.json
graph/
__init__.py
react.py
skills/
agent-skills/
SKILL.md
references/
skill-concepts.md
agentflow.md
claude.md
codex.md
github.md
.env
To initialize in a different directory without changing folders:
agentflow init --path ./my-agent-project
What each file does
agentflow.json
This is the core server configuration file. The default content:
{
"agent": "graph.react:app",
"thread_name_generator": null,
"env": ".env",
"auth": null
}
Field explanation:
agent(required) — the import path to your compiled graph, expressed asmodule:attribute. The loader imports the module and retrieves the attribute (usually aCompiledGraphinstance). In this case, it imports thegraph.reactmodule and retrieves theappvariable.env(optional) — path to a.envfile containing environment variables. These are loaded withpython-dotenvbefore the graph module is imported, so you can reference them in your graph initialization.thread_name_generator(optional) — import path to a thread name generator. When set, the API uses it to create human-readable thread names (e.g.,thoughtful-dialogue) automatically when threads are created.auth(optional) — authentication configuration. Set tonullfor no auth,"jwt"for JWT bearer tokens, or a custom auth backend configuration.
graph/react.py
A starter ReAct (Reasoning and Acting) agent. This is a reference implementation using Google's Gemini model. The example shows:
- How to define a simple state type with message history
- How to create a graph with a single agent node
- How to compile the graph (which enables checkpointing and real-time updates)
- How to prepare the graph as a FastAPI route (via
graph.invoke()andgraph.stream()) - How to discover the generated
skills/directory and expose aset_skilltool
You must keep an app variable defined that holds the compiled graph. Replace the graph logic with your own while preserving this export.
skills/
Starter agent skill library for Claude, AgentFlow agents, Codex, and GitHub workflows. It follows a compact main-file plus references structure:
skills/agent-skills/SKILL.md— main skill entry point and reference mapskills/agent-skills/references/skill-concepts.md— skill layout, frontmatter, resources, and validationskills/agent-skills/references/agentflow.md— AgentFlow graph andSkillConfigpatternsskills/agent-skills/references/claude.md— Claude-facing repository guidanceskills/agent-skills/references/codex.md— Codex skill authoring workflowskills/agent-skills/references/github.md— GitHub MCP and repository automation workflow
The generated graph/react.py discovers this folder and adds a set_skill tool so the model can load agent-skills and request exact reference files during a run.
.env
Stored environment variables for local development. The default is empty. Add API keys and connection strings here:
# Example
GOOGLE_API_KEY=your_key_here
REDIS_URL=redis://localhost:6379/0
The agentflow.json field env tells the server which .env file to load.
Overwrite existing files
If you have already initialized a project and want to regenerate the starter files:
agentflow init --force
This overwrites agentflow.json, graph/__init__.py, graph/react.py, and generated files under skills/. Use --force carefully—it will replace existing code and skill instructions.
Initialize a production project
The --prod flag scaffolds additional files for a professional project layout:
agentflow init --prod
This creates:
pyproject.toml— Python package definition (allowspip install -e .).pre-commit-config.yaml— Git hooks for code quality checks (linting, formatting)- Standard project structure with
src/,tests/, anddocs/directories
Use --prod when you are setting up a project that will be deployed or shared with a team.
Verify the initialization
After running init, verify the files were created:
ls -la
cat agentflow.json
cat graph/react.py
You should see valid Python and JSON files with no syntax errors.
Test the starter agent
Before modifying the starter agent, test that it runs:
# Set a Gemini API key if you want to test the starter
export GOOGLE_API_KEY=your_key_here
# Start the server
agentflow api --host 127.0.0.1 --port 8000
In another terminal, test the agent:
curl -X POST http://127.0.0.1:8000/v1/graph/invoke \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "What is 2+2?"}],
"config": {"thread_id": "test-1"}
}'
Expected response: A JSON object with messages, including the agent's response.
If this fails, check:
- Is the server running? (
curl http://127.0.0.1:8000/pingshould return{"success": true, "data": "pong"}) - Is
GOOGLE_API_KEYset? (The starter example requires it) - Are there errors in the server logs?
Next steps
- Replace the agent — Edit
graph/react.pywith your custom graph logic. See concepts for how graphs work. - Add tools — Give your agent callable functions via
ToolNode. See add a tool guide. - Add persistence — Configure a checkpointer in
agentflow.jsonso conversations persist across server restarts. See configure agentflow.json. - Start the server — Run
agentflow apito expose your agent over HTTP. - Test with the playground — Use
agentflow playto test interactively in a browser.
Troubleshooting
Error: "ModuleNotFoundError: No module named 'agentflow_cli'"
- Install the CLI:
pip install 10xscale-agentflow-cli
Error: "No such file or directory: agentflow.json"
- Make sure you run
agentflow initfrom the project root, or use--pathto specify the directory.
Error: "Overwrite existing files?" but you did not pass --force
- The CLI prompts interactively. Type
yesor pass--forceto skip the prompt.
The generated graph/react.py has syntax errors
- This is unusual. Try deleting the directory and re-running
agentflow initfrom scratch.