Skip to content

Builder

You have a problem. You know what you want a team of agents to do. You don’t want to hand-wire a workflow DAG, write five role prompts, figure out gate commands, and structure the handoff channels yourself.

So don’t.

Terminal window
cliq builder generate -m "Due diligence team that reads a data room from Google Drive, produces financial analysis, legal risk assessment, and a consolidated report, with a quality gate before delivery"

That’s it. One sentence. The builder reads your intent, designs a workflow DAG, writes every role prompt, adds quality gates with real shell commands, wires up connectors for external data, generates A2A metadata for discovery, validates the whole thing, and writes it to your current directory — ready to run.

✓ Team 'due-diligence-pipeline' created
Path: /Users/you/teams/due-diligence-pipeline
Phases: 5
Roles: 4
Workflow:
financial-analyst [standard] (root)
legal-analyst [standard] (root)
report-writer [standard] → depends on financial-analyst, legal-analyst
quality-gate [gate] → depends on report-writer
fixer [support section]
Install: cliq team install /Users/you/teams/due-diligence-pipeline
Then: cliq assemble due-diligence-pipeline

From there:

Terminal window
cliq team install .
cd ~/src/my-project
cliq assemble due-diligence-pipeline
cliq req -m "Evaluate the Series B data room for Acme Corp"
cliq run

The builder needs an LLM provider to generate teams. Add a builder section to ~/.cliqrc/settings.json:

{
"builder": {
"provider": "google",
"api_key": "AIza...",
"model": "gemini-2.5-pro"
}
}

Three providers are supported:

Providerprovider valueDefault modelBest for
Google"google"gemini-2.0-flashFast generation, good value
OpenAI"openai"gpt-4oStrong reasoning, reliable structure
Anthropic"anthropic"claude-sonnet-4-20250514Nuanced role prompts, detailed analysis

You can override the provider or model on any command with --provider and --model:

Terminal window
cliq builder generate -m "..." --provider anthropic --model claude-sonnet-4-20250514

The generate command is the builder’s main act. Give it a description — as brief or as detailed as you like — and it produces a complete, validated team.

Terminal window
cliq builder generate -m "TDD pipeline for a Node.js Express API with linting, type checking, and security audit"

The builder infers the right phases, dependencies, gate commands, and role prompts. It knows that a TDD pipeline needs an architect, a developer, a test gate with npm test, and probably a fixer support phase for when tests fail.

For complex teams, write a detailed spec and pass it with -f:

Terminal window
cliq builder generate -f team-spec.txt

Pipe from scripts or heredocs with --stdin:

Terminal window
cat <<'EOF' | cliq builder generate --stdin
Content production pipeline for a technical blog.
Phases:
1. A researcher who gathers background material on the topic
2. A writer who produces a draft blog post (1500-2000 words)
3. A technical reviewer who checks accuracy and code examples
4. An editor who polishes prose and ensures consistent tone
5. A quality gate that verifies the final post meets our style guide
The researcher should read source material from a Google Drive folder.
The final approved post should be pushed back to Google Drive.
EOF

Not sure what you’ll get? Preview without writing anything:

Terminal window
cliq builder generate -m "Security audit team" --dry-run

This shows the full file list, workflow DAG, and role names — but writes nothing to disk.

The builder writes directly into the current directory (or the [path] argument if provided). Create a directory for your team first:

Terminal window
mkdir my-team && cd my-team
cliq builder generate -m "TDD pipeline for Node.js"

Or specify a path:

Terminal window
cliq builder generate -m "TDD pipeline for Node.js" ./my-team

If team.yml already exists in the target directory, use --force to overwrite:

Terminal window
cliq builder generate -m "..." --force

The builder picks a name from your description. Override it with --name:

Terminal window
cliq builder generate -m "..." --name my-custom-team

The --name flag sets the name field in team.yml — it doesn’t affect where files are written.


A single generate call produces an entire team directory:

./
├── team.yml # Workflow DAG, phase definitions, A2A metadata
├── roles/
│ ├── architect.md
│ ├── developer.md
│ ├── reviewer.md # Gate role with evaluation criteria
│ └── fixer.md # Support phase role (activated by gate routing)
└── README.md # Auto-generated overview

The workflow definition includes correctly ordered phases, dependency edges, gate commands with real shell commands, and (when your description mentions external data) pull and push declarations:

name: tdd-express-api
description: TDD pipeline for a Node.js Express API with linting, type checking, and security audit.
tags: [code, tdd, nodejs, express, api]
use_when:
- Building a new Express API endpoint or service
- Adding features that require comprehensive test coverage
not_for:
- Frontend-only changes with no backend component
- Infrastructure or deployment tasks
workflow:
phases:
- name: architect
type: standard
- name: developer
type: standard
depends_on: [architect]
- name: quality-gate
type: gate
depends_on: [developer]
commands:
- name: lint
run: npm run lint
- name: typecheck
run: npx tsc --noEmit
- name: tests
run: npm test
- name: security
run: npm audit --audit-level=moderate
max_iterations: 3
support:
- name: fixer
type: standard

Each role gets a detailed prompt with identity, objective, context, deliverables, constraints, and handoff instructions. Gate roles describe evaluation criteria in plain language — the orchestrator automatically injects the verdict protocol at runtime:

# Role: Quality Gate
You are a senior QA engineer responsible for verifying that the implementation
meets all quality standards before release.
## Context
Read the implementation from the developer's outgoing channel and review it
against the architectural design.
## Gate Evaluation
Run the automated commands and review code quality:
- If ALL commands pass and the code follows the design:
approve and proceed
- If tests fail or linting issues are fixable:
route to fixer for remediation
- If the implementation has fundamental design flaws:
escalate to a human

Every generated team includes top-level A2A metadata fields, making it discoverable by other agents in A2A meshes:

tags: [code, tdd, nodejs, express, api]
use_when:
- Building a new Express API endpoint or service
- Adding features that require comprehensive test coverage
not_for:
- Frontend-only changes with no backend component
- Infrastructure or deployment tasks

Generated teams are good. With a few rounds of refinement, they’re great.

The improve command takes an existing role and makes it sharper — more specific instructions, better-defined deliverables, concrete examples:

Terminal window
cliq builder improve my-team --role architect

Without any instruction, the LLM reviews the role in context of the full team and improves it using its own judgement. With an instruction, you direct the improvement:

Terminal window
cliq builder improve my-team --role developer --instruction "add error handling patterns and logging conventions"
cliq builder improve my-team --role reviewer --instruction "add OWASP top 10 security checklist"

The output shows what changed:

ℹ Improving role 'developer' — "add error handling patterns"...
ℹ Changes:
Added structured error handling section with try/catch patterns,
custom error classes, and logging conventions using Winston.
Original: 45 lines, 2340 chars
Improved: 72 lines, 3891 chars
✓ Role 'developer' updated in ~/.cliqrc/teams/@local/my-team/roles/developer.md

Use --dry-run to preview changes before writing.

Pipe longer instructions from stdin:

Terminal window
echo "Focus on making the deliverables section extremely specific, with exact file paths and content structure for each output file" | cliq builder improve my-team --role writer --instruction -

The gaps command is your team’s peer review. It examines the workflow structure, role prompts, and overall coverage, then suggests concrete improvements:

Terminal window
cliq builder gaps my-team
ℹ Analysing team 'my-team'...
ℹ 3 suggestion(s):
1. [missing gate] Add integration test gate
The pipeline runs unit tests but has no integration test phase.
Tests may pass individually but fail when components interact.
→ suggested phase: integration-gate [gate]
2. [workflow improvement] Parallelize independent analysts
The financial-analyst and legal-analyst phases have no dependency
on each other but are currently sequential. Running them in
parallel would halve the pipeline time.
3. [metadata enhancement] Add output definitions
The team is missing output definitions. Adding them
enables downstream A2A agents to understand what this team produces.

Each suggestion includes a type, explanation, and when applicable, a fully-defined phase and role that you can add manually.

If you’ve modified a team’s workflow or roles, regenerate the A2A metadata fields (tags, use_when, not_for) to keep them accurate:

Terminal window
cliq builder capability my-team
A2A metadata:
tags: finance, legal, analysis, due-diligence
use_when:
- Evaluating a company for investment or acquisition
- Performing regulatory compliance review
not_for:
- Real-time market trading decisions
- Personal tax preparation
✓ A2A metadata updated in ~/.cliqrc/teams/@local/my-team/team.yml

Tutorial: Build a Research Team from Scratch

Section titled “Tutorial: Build a Research Team from Scratch”

Let’s walk through the full builder workflow — from idea to running pipeline.

You want a team that reads a Google Doc, researches the topic, writes a comprehensive analysis, and pushes the result to Google Drive.

Terminal window
mkdir research-team && cd research-team
cliq builder generate -m "Research team that pulls a question from a Google Doc, researches the topic using the document's context, writes a detailed analysis with citations, and pushes the final report to a Google Drive folder. Include a quality gate to verify completeness."

The builder produces a team with phases like researcher, writer, quality-gate, and a fixer support phase. The first phase uses a connector agent with sources for the Google Doc, and a later phase uses target_entries for Google Drive.

Look at what was generated:

Terminal window
cat team.yml

Read a specific role (team packages store one file per role under roles/):

Terminal window
cat roles/researcher.md

Maybe the writer role is too generic. Sharpen it:

Terminal window
cliq builder improve research-team --role writer --instruction "emphasize structured arguments with evidence, include a methodology section, and require inline citations in [Author, Year] format"

Run a gap analysis:

Terminal window
cliq builder gaps research-team

If it suggests adding a fact-checker phase, you can add it manually with cliq team add-phase or regenerate with a more detailed description.

Terminal window
cliq team install .
cd ~/src/my-project
cliq init
cliq assemble research-team
cliq req -m "What are the competitive dynamics in the enterprise AI agent market?" \
--input source_document_url="https://docs.google.com/document/d/abc123/edit" \
--input output_folder_url="gdrive://1NheCF5I0pB_c4SJ1s0EJhUbsQ7cyPmrE"
cliq run

The pipeline fetches the Google Doc, runs the research and writing phases, verifies quality, and publishes the final report to Google Drive — all automated, all from one command.

After a run, improve based on what you observed:

Terminal window
cliq builder improve research-team --role researcher --instruction "be more thorough about finding contrarian viewpoints"
cliq builder improve research-team --role quality-gate --instruction "add check for minimum word count of 2000"

Each improvement is instant. Reassemble, re-req, re-run.


The builder can embed existing teams as sub-steps in a larger workflow. Reference installed teams by their @scope/name in your description:

Terminal window
cliq builder generate -m "CI pipeline that runs @acme/security-audit on the source, then @acme/perf-suite for benchmarks, then synthesizes both into a release-readiness report"

The builder resolves each referenced team from your local registry, injects its metadata (inputs, outputs, phases) into the LLM context, and generates:

  • A type: team phase for each referenced sub-team
  • A role-as-spec for each team phase — a requirement document that the sub-team executes against (not agent instructions)
  • Correct $(dirs.*) path stitching so sub-team outputs are wired to downstream phases
  1. The builder extracts @scope/name references from your intent
  2. Each must be locally installed — if any are missing, the builder errors immediately
  3. The LLM receives each team’s inputs, outputs (with scope), and phase structure
  4. It generates team phases with role-as-spec content and correct path wiring
  5. The validator enforces that only the referenced teams appear in the output

Team phases are different from standard phases. Their role file is a requirement specification passed to the sub-team via cliq req, not instructions for an AI agent. The builder writes them in spec voice:

# Security Audit
Scan the application source at $(dirs.project)/src/ for vulnerabilities.
Focus on high and critical severity findings only.
## Inputs
- **target**: $(dirs.project)/src/
- **severity**: high
## Expected Output
Write the full audit report to $(dirs.self)/reports/security-audit.md.
Include vulnerability count, severity breakdown, and remediation steps.

The builder’s primary value for team composition is correct $(dirs.*) wiring:

VariableUsage
$(dirs.project)/Project root — for source files and project-scoped deliverables
$(dirs.self)/Sub-team’s local output directory — for intermediate artifacts
$(dirs.<phase-name>)/Sibling team phase’s output — for cross-references

Downstream standard phases access sub-team output via $(dirs.<team-phase>)/path and receive an automatic channel handoff summary.

  • Referenced teams must be installed locally (cliq team install <path>)
  • If no @scope/name references appear in your intent, team phases are disabled entirely
  • The builder never proactively suggests team composition — it only follows explicit references

Be descriptive. The more context you give the builder, the better the output. “Code review team” produces something generic. “Code review team for a React TypeScript monorepo with Playwright e2e tests, focusing on accessibility compliance and performance budgets” produces something you can actually use.

Use --dry-run first. Especially for complex teams. Preview the structure before committing.

Iterate with improve. The first generation is a starting point. Two or three rounds of targeted improvements — with specific instructions — produce significantly better role prompts.

Run gaps after manual edits. If you’ve added phases or modified roles by hand, gaps catches structural issues you might have introduced.

Use -f for complex descriptions. For teams with many requirements, write the description in a file and pass it with -f. The builder handles multi-paragraph, detailed specifications.

Override models for quality. For critical teams, use a stronger model: --provider anthropic --model claude-sonnet-4-20250514 or --provider google --model gemini-2.5-pro. For quick experiments, the defaults are fast and cheap.


Under the hood, the builder is a structured generation pipeline:

  1. Team context resolution — If your intent references @scope/name teams, the builder resolves each from your local registry, extracts their metadata (inputs, outputs, scope, embedding-awareness), and prepares context for the LLM. If any referenced team isn’t installed, the builder errors before calling the LLM.

  2. Prompt composition — Your description is combined with a comprehensive platform reference that teaches the LLM everything about cliq: phase types, channel conventions, signal protocols, connector semantics, gate verdicts, and the filesystem contract. When team context is present, it also includes sub-team metadata, role-as-spec writing rules, and $(dirs.*) stitching rules. The LLM doesn’t guess how cliq works — it’s told.

  3. LLM generation — The composed prompt is sent to your configured provider. The LLM returns a structured JSON object containing the team name, description, A2A metadata, workflow phases (with dependencies, commands, connectors, team refs), and full role prompts (including role-as-spec for team phases).

  4. Parsing — The raw LLM output is parsed and extracted into typed structures. The parser handles JSON embedded in markdown fences, trailing commas, and other common LLM output quirks.

  5. Validation — Every generated team is validated before writing: phase names are unique and kebab-case, role names match phase names, gate phases have commands, dependencies reference real phases, support phases are referenced by gates, the DAG has no cycles, team phase refs match the resolved set, and team phase roles use spec voice (not agent instructions).

  6. Write to disk — The validated team is written directly to the target directory as a team.yml, individual role files under roles/, and an auto-generated README.md.

The same engine powers improve (targeted role refinement), gaps (structural analysis), capability (A2A metadata generation), and the server-side A2A builder skills.


CommandWhat it does
cliq builder generate -m <text> / -f <file> / --stdinGenerate a complete team from a description
cliq builder improve <team> --role <name>Improve a specific role with optional --instruction
cliq builder gaps <team>Analyse a team for structural gaps and suggest improvements
cliq builder capability <team>Generate or regenerate A2A metadata (tags, use_when, not_for)

All commands accept --provider <name> and --model <model> overrides. See the full CLI Reference for all options.