Freestyle Cognition

Explain this chapter with AI

Copy this prompt into ChatGPT, Claude, Gemini, a local model, or another AI.

Apply this chapter with AI

Copy this prompt into ChatGPT, Claude, Gemini, a local model, or another AI.

What Is Freestyle Cognition?

Freestyle cognition is a way of working where conversation, research, prototyping, testing, revision, and writing happen in one fluid loop.

The previous chapter treated AI as a lens for choosing what deserves attention. Here the lens becomes active. Selected information turns into questions, questions turn into prototypes, prototypes produce evidence, and evidence changes the next question.

You do not begin with a complete specification. You begin with curiosity:

What is this idea?
What could I build from it?
What would a small prototype look like?
What breaks when I run it?
What did I learn?
What should I try next?

The agentic system becomes a thinking surface. It can summarize, propose structures, generate code, compare alternatives, explain errors, and help you keep momentum.

The human still owns direction and judgment. The model supplies variation and scaffolding. Tools supply evidence. Tests tell you what actually works.

That mix is the method.


Try It With a Paper

A simple freestyle session can start with a paper.

For example, you might choose Towards an AI Co-Scientist or any other paper related to a problem you care about.

Start with:

Summarize this paper for an engineer.
Then identify:
- the main system components
- what could be prototyped in a weekend
- which claims would need experimental evidence
- what a small implementation might deliberately leave out

Then ask:

Turn the prototype idea into a minimal project plan.
Give me:
- modules
- data structures
- external dependencies
- risks
- first tests

Now the paper is no longer only something you read. It has become a source of possible systems.

That does not mean the generated design is correct. It means you have a first candidate to inspect.


Choose a Stack Deliberately

The model may suggest tools quickly. Do not accept the stack automatically.

Ask why each part is needed:

Tool Possible purpose Question to ask
Hydra configuration for experiments Do we need multiple configs yet?
DSPy declarative LM programs and optimization Are we optimizing prompts/programs now or later?
PostgreSQL durable structured storage Would SQLite be enough for the prototype?
pgvector vector search in PostgreSQL Do we need semantic retrieval?
Ollama local model serving Is local inference good enough for this task?

The freestyle habit is not “use every interesting tool.” It is “make options visible, then choose.”

That choice needs a budget. Open-ended exploration can expand forever: another source, another prototype, another architecture, another critique. A useful freestyle session decides how many branches to try, what evidence would make a branch worth keeping, and when to stop.

For a first prototype, simpler is usually better. A single Python package, a few JSONL files, and pytest may teach you more than a complex stack that never runs.


Build the Map Before the Code

Before asking for implementation, ask for the project shape:

Print the proposed project structure.
For each file, explain:
- why it exists
- what it imports
- what it exports
- how I would test it

A useful result might look like this:

ai_co_scientist/
  agents/
    generation.py      -> propose candidate hypotheses
    reflection.py      -> critique candidates against criteria
    ranking.py         -> compare candidates and keep a trace
    evolution.py       -> revise or combine stronger candidates
  memory/
    store.py           -> persist hypotheses and reviews
  supervisor.py        -> coordinate the pipeline
  run_pipeline.py      -> command-line entry point
tests/
  test_supervisor.py
  test_generation.py
  test_ranking.py
README.md

This structure is not proof that the system works. It is a checklist. When the model later generates files, you can compare the output against the map.


Generate, Then Reconcile

Generated projects often have missing files, mismatched imports, placeholder functions, or dependencies that were mentioned but not installed.

Treat that as normal.

After generating code, ask:

Compare the files that exist with the project structure you proposed.
List:
- missing files
- imports that cannot resolve
- functions referenced but not implemented
- tests that should exist before we trust the pipeline

Then run the project yourself. Do not rely on the model’s statement that it should work.

When errors appear, feed back the useful evidence:

Here is the failing command.
Here is the traceback.
Here are the files involved.
Please propose the smallest fix.
Do not rewrite unrelated code.

The loop is:

generate
  โ†“
run
  โ†“
observe failure
  โ†“
repair
  โ†“
test

This is where freestyle cognition becomes more than brainstorming. The environment pushes back.

You can treat the work as a small trajectory search:

generate candidate branches
  โ†“
run cheap checks
  โ†“
keep the branches with evidence
  โ†“
cancel branches that stop paying rent
  โ†“
commit one path or preserve several

The point is not to mechanize creativity. It is to keep creative momentum from turning into unbounded churn.

    flowchart TD
    G[Generate branches] --> C[Cheap checks]
    C --> K{Evidence worth keeping?}
    K -->|yes| P[Preserve branch]
    K -->|no| X[Cancel branch]
    P --> D{Budget remaining?}
    D -->|yes| G
    D -->|no| A[Choose or archive paths]
  

Tests Turn Exploration Into Progress

Once the project has a shape, ask for tests.

For an AI co-scientist style prototype, the core tests might be:

Component Test
Pipeline runner loads configuration and starts the supervisor
Supervisor calls generation, reflection, ranking, and review in order
Generation agent returns structured hypotheses
Reflection agent reviews every candidate against criteria
Ranking agent produces a comparison trace
Evolution agent revises or combines selected candidates
Memory store writes and retrieves records
CLI accepts a goal and prints a run summary

Some tests can be deterministic. Use them first. Mock the model where possible. Test schemas, routing, logs, and data flow before testing model quality.

Model-backed tests are useful too, but they are slower, more expensive, and less repeatable. Label them clearly.

unit tests:
  deterministic logic

integration tests:
  file system, database, CLI

model tests:
  quality and behavior under real LM calls

This distinction keeps the project from becoming a pile of generated files that only appears to work.


Mark, Revert, Reboot

Freestyle work can get messy. Context grows. The idea changes. The model follows an unhelpful branch. The code becomes too large.

Use markers:

Call this Version A.
It uses JSONL memory and no database.
Do not move past this baseline until tests pass.

If the next branch fails:

Return to Version A.
Keep the tests.
Try adding retrieval without changing the supervisor interface.

This is versioning from Chapter 5 applied to exploration. You are free to wander because you know how to return.

Use Git when files exist. Commit small working states. Let the conversation stay fluid, but make the artifact recoverable.


Resyncing With the Agent

At some point you will edit files outside the chat. The agent’s mental picture of the project will become stale.

Resync it:

Here is the current project tree.
Here are the key files.
Forget the older proposed structure where it conflicts with this.
Tell me what is implemented, what is missing, and what should be tested next.

If your tool supports uploading a zip or reading the repository directly, use that. If not, paste the smallest useful slices: project tree, failing file, traceback, and test names.

The goal is to make the conversation match the artifact again.


What Freestyle Cognition Is Good For

Freestyle cognition is strongest when the problem benefits from exploration:

  • turning a paper into a prototype;
  • learning a new technical area;
  • sketching a product idea;
  • comparing architectures;
  • generating examples;
  • debugging unfamiliar code;
  • writing and revising public explanations;
  • moving between research, code, and prose.

It is weaker when the task requires formal certainty, high-stakes judgment, secret information, or exact compliance without independent verification.

The rule is simple:

use the agent for variation and momentum
use tools and tests for evidence
use human judgment for direction

Appendix: Co-Intelligence Session

A fuller example session is available here:

programmer.ie/post/cointelligence

Source code:

github.com/ernanhughes/cognitive-freestyle

Those links are examples, not proof that every generated project works out of the box.


When the Awe Hits

There is a real moment in this workflow when the distance between idea and artifact feels dramatically shorter.

You read a paper in the morning. By the afternoon you have a project structure, a prototype, tests, a README, and a list of open questions. It may be rough. It may be incomplete. But it exists, and you can now react to it.

That is the value of freestyle cognition.

Not instant mastery. Not automatic science. Not a guarantee that the model is right.

A faster loop:

read
  โ†“
ask
  โ†“
build
  โ†“
run
  โ†“
revise
  โ†“
explain
    flowchart TD
    A[Find an idea or concept]
    B[Open a conversation with AI]
    C[Ask questions]
    D[Explore possibilities]
    E[Build prototypes]
    F[Generate new understanding]
    G[Try a new version]
    H[Build something real]
    I[Run, test, and revise]

    A --> B
    B --> C
    B --> D
    B --> E
    C --> F
    D --> F
    E --> F
    F --> G
    G --> H
    H --> I
    I -->|Iterate| B
  

Freestyle cognition is what happens when that loop becomes natural. It is exploratory, technical, creative, and human-led.

At this point the machinery has done its work. Roles, tools, memory, reflection, versioning, lenses, and tests have become one working rhythm. The remaining question is not what else the system can do, but what all this capability is for.