Skip to content

Automated Workflow — Linear Issue → Pull Request

1. Complexity Gate & Three-Tier Routing

Every task passes through a complexity gate before the agent chain runs:

Issue with labels ["plan"]
  → resolve_tier(labels)   # checks for "premium"/"claude" override
  → if no override: classify_complexity(title, description)
  → routes to SIMPLE | MEDIUM | COMPLEX | PREMIUM
  → each agent gets its assigned provider

Tier Decision Table

TierTriggerPMArchitectCoderReviewerHealer
SimpleclassifierOllamaOllamaOllamaOllamaOllama
MediumclassifierDeepSeekDeepSeekDeepSeekDeepSeekDeepSeek
ComplexclassifierDeepSeeko3-minio3-minio3-miniDeepSeek
PremiumlabelDeepSeekClaudeClaudeClaudeDeepSeek

Fallback Safety (Claude is NEVER used unless premium label is set)

PrimaryFalls back to
OllamaDeepSeek → error
DeepSeekerror (Cheapest cloud — no further fallback)
o3-miniDeepSeek → error
Claudeo3-mini → DeepSeek → error

2. Tag-Based Two-Phase Trigger

Linear Issue created/updated with tag "plan" or "implement"
  → n8n webhook → POST /webhook to pipeline.py (Mac Studio)
  → projects.yaml lookup (team_id → repo, base_branch, trigger_labels)
  → complexity gate → Execute phase based on tag

2. Phase: Plan (tag: "plan")

3. Phase: Implement (tag: "implement")

4. 6-Agent Chain

AgentRoleInputOutputDefault Provider
PMSpec generationIssue title + bodyJSON: spec, acceptance_criteria, files, riskOllama (simple) / DeepSeek (medium+)
ArchitectTechnical planningSpec + plan.mdJSON: file_plan, invariants, test_planOllama / DeepSeek / o3-mini / Claude
CoderCode generationPlanJSON: file contents + commandsOllama / DeepSeek / o3-mini / Claude
ReviewerCode reviewGit diffJSON: overall, issues, summaryOllama / DeepSeek / o3-mini / Claude
HealerAuto-fixDiff + review issuesJSON: fixed filesOllama / DeepSeek
ReleasePR managementBranch, title, bodyPR URLOllama / DeepSeek

5. Multi-Repo Configuration

Edit projects.yaml to map Linear teams to GitHub repos:

yaml
projects:
  healthtech:
    linear_team_id: "TEAM_UUID_1"
    github_repo: "org/healthtech"
    trigger_labels:
      plan: "plan"
      implement: "implement"

6. Cost Control

TierCloud Cost/TaskMonthly (60 tasks)
Simple (24 tasks)$0$0
Medium (24 tasks)~$0.01~$0.24
Complex (12 tasks)~$0.08~$0.96
Classification overhead~$0.001~$0.06
Total~$1.26

Claude Premium only activates when you tag an issue with premium or claude. At ~$0.30/task, using it for 5 tasks/month adds ~$1.50 — still well under $20.

7. Error Handling

FailureRetryEscalation
LLM timeoutTier-aware fallback chainTelegram notify
Review blockedStop, notify human
Review changes_requestedHealer agent (max 3)Human review via Telegram/PWA
Git push conflictRebase + retryTelegram notify
All providers downGrafana alert + Telegram

MIT Licensed | Built with AI Dev Station