CLIco init
DocsCLIco init

co init

Add ConnectOnion to an existing folder safely. Preserves your code and .env, appends only what's missing, refreshes docs to the latest version.

Quick Start: cd existing-project && co init โ€” your existing files stay put, ConnectOnion slots in around them.

init vs create

Use co create for a fresh project in a new directory. Use co init when you already have a folder โ€” Django app, scripts, or an existing ConnectOnion project you want to refresh.

Featureco createco init
Creates new directoryYesNo (uses current)
Works in non-empty dirNoYes
Uses global identity (~/.co/)YesYes
Handles existing .envCreates freshAppends missing keys
Refresh docs anytimeOn creationEvery run / --update-docs

Basic Usage

Drop into any directory and run co init:

code
cd my-existing-project co init
output
๐Ÿง… ConnectOnion Project Initializer
========================================
ย 
โœ“ Using global identity from ~/.co/
โœ“ Found existing .env file
โœ“ Appending API keys from ~/.co/keys.env
โœ“ Wrote .co/host.yaml
โœ“ Refreshed .co/docs/
ย 
โœ… ConnectOnion project initialized!

Common one-liners:

Terminalbash
$co init
$co init -y
$co init -t minimal
$co init -t playwright
$co init --update-docs

What Gets Added

co init adds a small set of files. Everything else in your project stays exactly as it was.

Files created:

your-project//
โ”œโ”€โ”€๐Ÿagent.py# added if missing โ€” never overwritten
โ”œโ”€โ”€.env# created or appended with missing API keys
โ”œโ”€โ”€.co//
โ”œโ”€โ”€host.yaml# project config โ€” uses global identity
โ””โ”€โ”€docs//# always refreshed to latest
โ”œโ”€โ”€connectonion.md
โ””โ”€โ”€co-vibe-coding-all-in-one.md
โ””โ”€โ”€.gitignore# ConnectOnion entries appended

Identity (address + email) lives in ~/.co/keys.env and ~/.co/host.yaml โ€” shared across every project. The per-project .co/host.yaml only stores project-specific overrides.

File Safety

Each file has a clear, predictable behavior. Your code is never touched.

File / DirectoryIf ExistsBehavior
agent.pySkipWon't overwrite your code
.envAppendAdds only API keys that are missing
.co/docs/OverwriteAlways pinned to latest framework docs
.co/host.yamlUpdateMerges, preserves custom keys
.gitignoreAppendAdds ConnectOnion entries if missing

How .env Is Merged

Global API keys live in ~/.co/keys.env. co init reads them and intelligently merges into your project's .env โ€” four cases, all safe.

Case 1 โ€” No .env File

Creates a fresh .env with your global keys.

code
co init
output
# .env (created)
OPENAI_API_KEY=sk-proj-xxx
ANTHROPIC_API_KEY=sk-ant-xxx
GEMINI_API_KEY=AIza...

Case 2 โ€” .env Exists, No API Keys

Appends the API keys section. Your variables stay intact.

code
# Original .env DATABASE_URL=postgres://localhost/mydb SECRET_KEY=mysecret
output
# After co init
DATABASE_URL=postgres://localhost/mydb
SECRET_KEY=mysecret
ย 
# ConnectOnion API Keys
OPENAI_API_KEY=sk-proj-xxx
ANTHROPIC_API_KEY=sk-ant-xxx

Case 3 โ€” .env Has Some API Keys

Existing keys are preserved. Only the missing ones are added.

code
# Original .env OPENAI_API_KEY=sk-proj-old
output
# After co init
OPENAI_API_KEY=sk-proj-old # untouched
ย 
# ConnectOnion API Keys
ANTHROPIC_API_KEY=sk-ant-xxx
GEMINI_API_KEY=AIza...

Case 4 โ€” .env Has All Keys

Nothing to do โ€” file isn't modified.

code
co init
output
โœ“ .env already contains all API keys

Provider mapping

When you pass --key, the provider is auto-detected from the prefix:

  • โ€ข OpenAI โ†’ OPENAI_API_KEY
  • โ€ข Anthropic โ†’ ANTHROPIC_API_KEY
  • โ€ข Google โ†’ GEMINI_API_KEY
  • โ€ข Groq โ†’ GROQ_API_KEY

Templates

Same templates as co create โ€” pick the closest fit, you can always edit afterward.

minimal

Basic agent with simple tools. Good starting point.

playwright

Browser automation โ€” clicking, scraping, screenshots.

custom

Describe what you want โ€” generated by AI.

code
co init -t minimal co init -t playwright co init -t custom --description "Monitor a site and alert me on changes"

Refreshing Docs

The .co/docs/ folder ships with the framework โ€” it's overwritten on every co init so the agent always has the current docs in context.

For a docs-only refresh in an existing project, use --update-docs:

code
co init --update-docs
output
โœ“ Project already initialized
โœ“ Updated .co/docs/ to latest version
ย 
โœ… Documentation updated!

Don't edit framework docs. They'll be overwritten on the next update. Put your own project rules in .co/OO.md instead โ€” that file is yours, never touched by init.

Special Directory Warnings

co init refuses (or warns) when run in directories that probably aren't projects:

  • โ€ข Home directory (~)
  • โ€ข Root directory (/)
  • โ€ข System directories (/usr, /etc)
  • โ€ข Existing git repositories โ€” warns, then continues

If you really mean it, pass --force:

code
co init --force

Command Reference

OptionShortDescription
--template-tminimal | playwright | custom
--keyโ€”Paste an API key โ€” provider auto-detected, appended to .env
--forceโ€”Continue in non-empty or special directories
--yes-yAccept defaults, skip prompts
--update-docsโ€”Refresh .co/docs/ only โ€” leaves everything else alone
--no-aiโ€”Disable AI features (not recommended)

Common Workflows

Add agents to a Django app

code
cd my-django-app co init
output
โœ“ Found existing .env file
โœ“ Appending API keys (DATABASE_URL preserved)
โœ“ Skipped agent.py (none found โ€” created)
โœ“ Refreshed .co/docs/
ย 
โœ… ConnectOnion project initialized!

Refresh an older ConnectOnion project

code
cd old-agent-project co init
output
โœ“ Project already initialized
โœ“ Adding ANTHROPIC_API_KEY (was missing)
โœ“ Refreshed .co/docs/ to latest
ย 
โœ… Project updated!

Convert a scripts folder into an agent project

code
cd my-scripts co init -y
output
โœ“ Created .env with API keys
โœ“ Added agent.py template
โœ“ Your scripts untouched
ย 
โœ… Ready โ€” run: python agent.py

Troubleshooting

My .env had a different OPENAI_API_KEY โ€” was it overwritten?

No. co init never replaces an existing key. Your old value stays. To use the global one, delete the line and re-run co init.

The docs in .co/docs/ look out of date

Run co init --update-docs. The folder is always overwritten with the latest framework docs.

I want a clean .env from scratch

Remove it manually, then re-init: rm .env && co init.

Refused to run โ€” "special directory"

You're probably in ~, /, or a system path. Move into a project folder, or pass --force if you really mean it.

Best Practices

Review .env after init โ€” confirm the API keys appended cleanly.
Refresh docs periodically โ€” co init --update-docs keeps the agent's context fresh.
Commit .co/host.yaml โ€” track project-specific config in git.
Never commit .env โ€” keep API keys out of the repo.
Don't edit .co/docs/ โ€” it's framework-owned, overwritten on update. Put your rules in .co/OO.md.

Star us on GitHub

If ConnectOnion saves you time, a โญ goes a long way โ€” and earns you a coffee chat with our founder.