Contract First Agents logo

Contract First Agents

Community
happycapy-ai
contract-first-agents

Contract-First Map-Reduce coordination protocol for native TeamCreate multi-agent teams. Wraps TeamCreate, Task (teammates), SendMessage with an upfront shared contract phase that eliminates 75% of integration errors. Based on 400+ experiment research proving 52.5% quality improvement over naive coordination.

Overview

Publisherhappycapy-ai
RepositoryHappycapy-skills
Skill namecontract-first-agents
Stars
138
Forks
30
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by happycapy-ai on GitHub. Read the source before you install it.

Installation

Install the Contract First Agents AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/happycapy-ai/Happycapy-skills.git /tmp/Happycapy-skills
mkdir -p .claude/skills
cp -r /tmp/Happycapy-skills/skills/contract-first-agents .claude/skills/contract-first-agents
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Contract First Agents in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Contract First Agents on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Contract First Agents is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Contract-First Map-Reduce Agent Coordination

Wraps native TeamCreate/Task/SendMessage with a proven 4-phase protocol that eliminates 75% of integration errors in multi-agent tasks.

Research Basis

Based on 400+ controlled experiments comparing 7 coordination strategies:

  • Naive multi-agent: 0.571 composite quality score
  • Contract-First Map-Reduce: 0.871 composite quality score (+52.5%)
  • The contract alone accounts for the ENTIRE quality improvement
  • Validated across 2-64 agent configurations

The Protocol

Phase 1: CONTRACT GENERATION (Team Lead, ~5% of time)

Before spawning ANY worker agent, the team lead MUST create a Contract Document.

The Contract Document must contain:

markdown
# === SHARED CONTRACT: [Project Name] ===

## 1. MODULE MANIFEST
For EVERY module/section an agent will produce:
- Exact filename
- Purpose (1 sentence)
- ALL exported names (exact spelling, exact case)

## 2. INTERFACE DEFINITIONS
For EVERY cross-module reference:
- Exact function/class name
- Exact parameter names and types
- Exact return type
- Source module -> consuming module(s)

## 3. SHARED TYPES
For EVERY data structure shared across modules:
- Exact field names and types
- Validation rules
- Serialization format

## 4. STYLE GUIDE
- Naming: snake_case for functions/variables, PascalCase for classes
- Indentation: [N] spaces
- Docstrings: [Google/NumPy/Sphinx] style on all public functions/classes
- Error handling: exact exception types
- Import convention: "from module import Name"
- Language-specific conventions

## 5. DEPENDENCY MAP
- Which modules import from which
- Execution order constraints (if any)
- Shared state / global configuration

## 6. SECTION BOUNDARIES
For EACH section assigned to an agent:
- What it must produce (exact deliverables)
- What it imports from other sections (exact names)
- What it exports for other sections (exact names)
- How it connects to adjacent sections (transitions, API calls, imports)

Contract Quality Checklist:

  • Every exported name is spelled out exactly
  • Every cross-module import has a matching export
  • Style guide is specific (not "be consistent" but "use snake_case")
  • Shared types have exact field names and types
  • No ambiguity - an agent reading only the contract can produce correct code

Phase 2: PARALLEL EXECUTION (Worker Agents)

Spawn worker agents using the Task tool with team_name parameter. Each worker's prompt MUST include:

[FULL CONTRACT TEXT - every worker gets the COMPLETE contract]

---

YOUR ASSIGNMENT: [Specific section/module]

You are Agent [N] of [Total]. You are producing [section name].

CRITICAL INSTRUCTIONS:
1. Follow the contract EXACTLY. Do not deviate from specified names, types, or conventions.
2. Your section will be merged with outputs from other agents working in parallel.
3. Use ONLY the exported names specified in the contract when referencing other modules.
4. Do NOT rename, reorganize, or "improve" the interface - follow the contract.
5. Write your output to: [exact file path]

Spawn all workers in parallel using a single message with multiple Task tool calls.

Phase 3: AUTOMATED VALIDATION (Team Lead or Script)

After all workers complete, the team lead validates the merged output:

python
# Validation checks (in priority order):
1. Syntax validity    - Can the output be parsed? (ast.parse, eslint --no-fix, etc.)
2. Import resolution  - Do all imports match actual exports?
3. Name consistency   - Is the naming convention uniform throughout?
4. Completeness       - Are all contracted exports present?
5. Style consistency  - Indent, docstrings, error handling patterns
6. Cross-references   - Do function calls use correct signatures?

Save validation results. If all pass -> done. If issues found -> Phase 4.

Phase 4: TARGETED FIX (Fixer Agent, only if needed)

Spawn ONE fixer agent that receives:

  • The merged output
  • The specific validation errors (exact line numbers, exact issues)
  • The original contract

The fixer ONLY fixes the specific issues found. It does NOT regenerate or restructure.

Implementation with Native Tools

python
# Step 1: Create team
TeamCreate(team_name="my-project", description="Building X with contract-first protocol")

# Step 2: Team lead generates the contract
# Save contract to a shared file: ~/.claude/teams/{team-name}/contract.md

# Step 3: Spawn workers with full contract in their prompts
Task(
    name="worker-auth",
    team_name="my-project",
    subagent_type="general-purpose",
    prompt=f"""
    {FULL_CONTRACT_TEXT}

    YOUR ASSIGNMENT: auth module
    Write to: /workspace/project/auth.py
    Follow the contract exactly.
    """
)
# ... spawn all workers in parallel

# Step 4: After workers complete, validate
# Team lead reads all output files and runs validation checks

# Step 5: If issues found, spawn fixer
Task(
    name="fixer",
    team_name="my-project",
    subagent_type="general-purpose",
    prompt=f"""
    Fix these specific issues in the merged output:
    {VALIDATION_ERRORS}

    Original contract: {CONTRACT}
    Do NOT restructure. Only fix the specific issues listed.
    """
)

# Step 6: Cleanup
SendMessage(type="shutdown_request", recipient="worker-auth")
# ... shutdown all workers
TeamDelete()

When to Use This Protocol

ALWAYS use for:

  • Any task requiring 3+ agents
  • Tasks producing code that must interoperate
  • Large document generation (multiple sections that reference each other)
  • Any task where agents produce outputs that will be merged

SKIP the contract for:

  • Completely independent tasks (no cross-references)
  • Single-agent tasks
  • Research/exploration tasks (no integration needed)

Key Principles

  1. The contract IS the coordination - review phases add <5% value if contract is good
  2. Every agent gets the FULL contract - not just their section's part
  3. Specific beats general - "use snake_case" beats "be consistent"
  4. Parallel beats sequential - contract enables parallel work; pipelines sacrifice speed for marginal gain
  5. Targeted fixes beat regeneration - fix specific issues, don't redo entire sections
  6. 10+ agents need validation - probability of ANY error increases with agent count

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Contract First Agents AI skill do?

Contract-First Map-Reduce coordination protocol for native TeamCreate multi-agent teams. Wraps TeamCreate, Task (teammates), SendMessage with an upfront shared contract phase that eliminates 75% of integration errors. Based on 400+ experiment research proving 52.5% quality improvement over naive coordination.

Why use Contract First Agents on TypingMind?

Because you install it once and use it with any model. Contract First Agents is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Contract First Agents in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/happycapy-ai/Happycapy-skills/tree/main/skills/contract-first-agents. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Contract First Agents?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Contract First Agents?

As many as you like. As long as a model supports skills, you can use Contract First Agents with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Contract First Agents AI skill free?

Yes. It is published on GitHub by happycapy-ai under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇