Quick Start: Build a Project From Scratch
This guide walks you through creating a CodeSpeak project from scratch. You'll write a spec, build it, add features, and fix bugs โ all by editing a Markdown file.
Prerequisites: Complete the Installation steps first.
Create a new project
mkdir my-project
cd my-project
codespeak initCodeSpeak will create a directory structure and initialise a git repo:
my-project
โโโ .codespeak # Internal state used by CodeSpeak
โโโ .gitignore
โโโ codespeak.json # CodeSpeak project configurationWrite a spec
Create/open spec.cs.md in your favourite editor, and type away. Here's an example that may be fun to start with:
# Funny Geese Demo
The app animates geese (๐ชฟ) bouncing around the screen, tumbling.
## UX
A click on a free space creates a new medium-sized goose flying in a random direction.
A click on a goose makes it bigger. When a goose gets too big it disappears with an animated pop.
## Technology
- Use pure HTML + JS
- Use Tailwind CSS for styling
Build
codespeak build spec.cs.mdWhen the build is finished, you'll see a message in the terminal:
โญโโโโโโโโโโโโ CodeSpeak Progress: Funny Geese Demo: Animating bouncing geese with click interactions โโโโโโโโโโโโโฎ
โ โ Process specification (0.1s) โ
โ โ Collect project information (0.1s) โ
โ โ Implement specification (39.9s) โ
โ โฐโ โ Collect context & plan work (39.7s) โ
โ โ Finalize spec build (0.2s) โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Alpha Preview โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Processing spec 1/1: spec.cs.md
Built successfully.
An HTML file will be created in the project dir, you can open it with your browser:
.
โโโ codespeak.json
โโโ index.html # <--- open this file
โโโ spec.cs.mdEnjoy the flying geese!
Add a feature
To improve your project, you can edit the spec and build again. CodeSpeak will turn the diff in the spec into a diff in the code. For example, let's add a slider to slow down/speed up the geese:
Now, let's build again:
codespeak build spec.cs.mdThe code has been updated. Check out the new version.
Add a Django back-end
Let's go for something more serious than just a self-contained HTML page:
Build the project:
codespeak build spec.cs.mdNow, you can start the Django server:
uv run manage.py runserverOpen the page in your browser, the URL is in your console (usually http://127.0.0.1:8000).
Remove a feature
If something doesn't seem like a good idea, edit the spec to remove it:
Build the project to see the changes:
codespeak build spec.cs.mdFix bugs by editing the spec
If you see that something is not right, first try to fix the spec:
codespeak build spec.cs.mdFix bugs with Code Change Requests
When the spec is correct, but the code doesn't work the way you expect, it presents a problem: there's nothing to change in the spec, but then how will the issue get fixed.
Typical examples would be
- either a bug in the code, e.g. an exception, or something not working as specified,
- or a low-level detail, like when you want to change a color of some element on the screen that is not even mentioned in the spec.
For these situations, CodeSpeak supports Code Change Requests through codespeak change command.
โ ๏ธ Note: Code Change Requests are supposed to only change the code without contradicting anything in the spec. For example, if you are trying to replace ๐ชฟ with ๐, it will report an error and ask you to change the spec.
For example, let's say we see that the number of geese is computed incorrectly for some reason. This is not a problem with the spec, it's a bug in the implementation.
So, let's tell CodeSpeak what's wrong in a Code Change Request:
codespeak change -m "Number of geese displayed is off by 1"CodeSpeak will try its best to fix the bug. See the Code Change Requests guide for more details.
Next steps
- Work in an existing project โ add CodeSpeak specs to an existing codebase
- Convert existing code to specs โ use
codespeak takeoverto generate specs from code - Managed files โ understand how CodeSpeak tracks generated files