codespeak takeover

โš ๏ธ CodeSpeak is in Alpha Preview: many things are rough around the edges. Please use at your own risk and report any issues to our Discord. Thank you!

Extract specifications from existing code โ€” either for specific paths you hand in, or for a whole project via an interactive modularization wizard.

Synopsis

codespeak takeover [paths...] [-o OUTPUT] [-f] [--cc-context | --no-cc-context] [--cc-session-dir DIR] [--cc-original-root PATH] [--no-interactive]

Description

Reads existing source code and generates spec files that capture its behavior. Generated specs are registered in codespeak.json, and from that point on you maintain the specs instead of the code.

Extracted specs capture what the code does โ€” its purpose, interfaces, and behavior โ€” without reproducing the code itself.

If no CodeSpeak project exists but the directory is inside a Git repo, takeover auto-initializes the project first.

Takeover modes

codespeak takeover runs in one of two modes depending on whether you pass paths.

Path-based

codespeak takeover src/module_a/ src/module_b.py

When paths are given, takeover produces a single spec file covering exactly those files. This is the right mode when you already know the module boundary you want to extract.

  • Output file defaults to <first-path-stem>.cs.md next to the source; override with -o.
  • -f overwrites an existing spec at the output path.

Module-based (modularization wizard)

codespeak takeover

When invoked with no paths, takeover analyzes the whole project, proposes a modular decomposition, and opens an interactive modularization wizard in your browser. You inspect the proposed modules, refine the structure (split, merge, rearrange responsibilities), and pick which modules to hand over. Confirming the plan writes one spec per selected module under specs/ and wires up their imports automatically.

Module metadata is recorded in .codespeak/ignored/modules.json so the wizard can resume where you left off.

-o is only valid in path-based mode โ€” in module-based mode, output paths are derived from module names.

Claude Code integration

By default, takeover reads your recent Claude Code session history to understand the intent behind the code. This produces richer specs that capture not just what the code does, but why it was written that way. Pass --no-cc-context to opt out of this enrichment.

On first use, CodeSpeak asks permission to read sessions:

CodeSpeak can read your Claude Code session history to better understand
the intent behind your code. Is this fine?

[Y] Allow  [N] Not now  [D] No, never

Your choice is recorded per-project in ~/.codespeak/preferences.json.

During the build, CodeSpeak shows which sessions and prompts it analyzed:

โœ“ Extract specification (2m 34s)
โ•ฐโ”€ โœ“ Analyze Claude Code sessions (0.0s) - 24 sessions, 150 prompts:
           "Implement @ideation/blog.md  Plan first",
           "react-dom-client.development.js:5530 Uncaught Error: Hydration failed because...",
           and 147 more
โ•ฐโ”€ โœ“ Write specification (2m 34s)

--cc-context / --no-cc-context explicitly force-enable or disable this enrichment, overriding the saved per-project preference. --cc-session-dir and --cc-original-root are for advanced cases where the session history is on a different machine or at a different path.

Flags

FlagDescription
pathsFiles or directories to extract a specification from. If omitted, opens the interactive modularization wizard
-o, --output OUTPUTOutput file path for the specification (relative to project root or absolute, must be under project root). Only valid when paths are given
-f, --forceOverwrite existing specification file if it exists
--cc-context / --no-cc-contextRead Claude Code session history to enrich spec extraction with original intent
--cc-session-dir DIRPath to a Claude Code session directory (overrides automatic discovery and skips consent)
--cc-original-root PATHProject root on the original machine (used with --cc-session-dir to remap foreign paths)
--no-interactiveRun in non-interactive mode without real-time progress updates

Error messages

ErrorCauseResolution
Anthropic API Key not foundNo API key configuredSet the ANTHROPIC_API_KEY environment variable or run through the interactive setup
{path} does not belong to a CodeSpeak projectNo codespeak.json foundRun codespeak init first
Specification file '{path}' already existsOutput spec file already existsUse -f to overwrite, or specify a different output with -o
Output path can not be a directory-o points to a directory, not a fileProvide a file path
No .codespeak/modules.json foundRunning takeover without paths and no module map existsRun /arch-explore in Claude Code to generate the module map, or provide explicit paths: codespeak takeover <paths>
No modules selected for takeover in .codespeak/modules.jsonModule map exists but no modules are marked for takeoverRun /arch-explore in Claude Code and select modules to take over
--output cannot be used with module-based takeover (no paths)-o flag used without explicit pathsEither provide explicit paths with -o, or omit -o for module-based takeover
--cc-original-root requires --cc-session-dirMissing session dir with original rootAlso specify --cc-session-dir
--output cannot be used with module-based takeover (no paths)--output passed without any paths, so takeover runs in module-based mode and produces multiple specsEither pass the path(s) you want extracted into a single spec, or drop --output to let the modularization wizard place the generated specs

See also