Competitor Researcher
[Live] ·
agent__competitor-researcher· Claude Sonnet 4.6
Researches 3–4 direct competitors to map their positioning, content strategy, and keyword gaps — giving the Context File Writer a clear picture of the competitive landscape.
Overview
| Function | Research competitor homepages via web search/fetch, then write a structured Markdown analysis |
| Type | Setup (part of the client context pipeline) |
| Model | Claude Sonnet 4.6 |
| Queue | agent__competitor-researcher |
| Concurrency | 3 |
| Timeout | 15 min (timeoutSec: 900) |
| Max turns | 20 (hard cap to prevent runaway web searches) |
| Est. cost / task | ~$0.35–0.45 |
| Plan | Free+ (all tenants) |
Triggers
| Trigger type | When | Who initiates |
|---|---|---|
| Auto (setup chain) | After Client Researcher completes on tenant registration or setup chain revision | Platform (event-chained from Client Researcher success) |
| Human on-demand | ”Refresh Competitors” button in Dashboard → Settings → Competitors | Tenant admin |
Can be skipped per-tenant: if contextConfig.enableCompetitorResearch = false, the setup chain jumps straight to Context File Writer with a placeholder.
Input
interface SetupJobData {
tenantId: string;
tenantName: string;
country: string;
plan: string;
clientResearchOutput: string; // full Markdown from client-researcher
knownCompetitors?: Array<{ name: string; domain?: string | null }>; // existing Competitor rows
revisionNotes?: string; // present on revision runs
wakeReason: WakeReason;
}knownCompetitors is loaded from the Competitor table at chain-time and passed as seed data so the agent doesn’t ignore previously tracked companies.
Output
The agent writes structured Markdown (not JSON). Output is passed as competitorResearchOutput directly to the Context File Writer.
Structure:
- One
##subsection per competitor (name, website, services, audience, channels, strengths/weaknesses) - Keyword gap table at the end
- Competitive landscape summary (intensity: low / medium / high)
How It Works
-
Receive job — BullMQ dequeues the job with
clientResearchOutputand optionalknownCompetitorsas seed. -
Skills dir created —
createSkillsDir()writessearch_knowledge.js+CLAUDE.md+ any DB-mapped skill files (e.g.competitor_analysis_framework.md) into a temp directory, which is passed to the Claude Code CLI via--add-dir. -
Agentic loop — Claude Code CLI runs with
--dangerously-skip-permissionsand a cap of 20 turns. The agent:- Does one
WebSearchper competitor to find their homepage URL - Does one
WebFetchper competitor (homepage only) - Synthesises findings into the Markdown output
- Does not fetch traffic data, SimilarWeb, Alexa, or Ahrefs
- Does one
-
Chain forward — On success, the worker enqueues a
context-file-writerjob with bothclientResearchOutputandcompetitorResearchOutput. -
DB log — A
ClientContextLogrecord is written withaction: "research_completed".
System Prompt (live in AgentConfig table)
You are the Competitor Researcher agent for Leadmetrics, a digital marketing agency AI platform.
Your task is to identify and analyse the top competitors for a client based on their niche, location, and services.
RESEARCH REQUIREMENTS:
1. Identify 3–4 direct competitors (same product/service category, overlapping geography). Stop at 4 — do not expand further.
2. For each competitor, do ONE web search to find their homepage, then fetch ONLY their homepage. Document:
- Company name, website URL
- Core products or services
- Apparent target audience
- Key marketing channels used (SEO, social, ads, email)
- Notable strengths and weaknesses
3. Perform keyword gap analysis: which high-value search terms do competitors likely rank for that the client does not? Base this on your homepage research — do NOT do additional searches for this.
4. Summarise overall competitive intensity (low / medium / high) with justification.
DO NOT:
- Look up traffic data, Alexa rank, SimilarWeb, or Ahrefs metrics
- Fetch more than 1 page per competitor
- Do more than 1 web search per competitor
- Research indirect or content competitors
OUTPUT FORMAT:
Write structured Markdown. Use a subsection per competitor. End with a competitive landscape summary and keyword gap table.
Output ONLY the competitor research notes. No preamble, no explanation.The system prompt is stored in AgentConfig.systemPrompt (role competitor-researcher) and can be updated via Manage → Agents without a redeploy. The seed in packages/db/src/seed.ts mirrors this value.
Skills Injected
| Skill file | Purpose |
|---|---|
search_knowledge.js | Query the tenant RAG knowledge base (all datasets) |
CLAUDE.md | Instructions for when/how to call search_knowledge |
competitor_analysis_framework.md | Scoring criteria and documentation structure for competitor research |
Tools Used (actual)
| Tool | Calls per run | Purpose |
|---|---|---|
WebSearch | 1 per competitor (3–4 total) | Find competitor homepage URL |
WebFetch | 1 per competitor (3–4 total) | Scrape competitor homepage |
Bash (search_knowledge.js) | 0–2 | Optional RAG lookup if tenant has uploaded competitor docs |
Total tool calls target: 8–12. Hard cap via --max-turns 20.
No SEMrush, SimilarWeb, or Alexa lookups — these were removed in April 2026 after they caused runaway tool call chains (31 calls, $1.30+/run).
Cost Profile
| Typical tool calls | 8–12 |
| Est. cost / task | ~$0.35–0.45 |
| Est. duration | ~2 min |
Before April 2026 tuning: 22+ WebSearch calls + 7+ WebFetch calls (traffic indicator lookups, SimilarWeb fetches that returned nothing useful) resulted in 31 tool calls, ~6.5 min, ~$1.30/run. Root causes: “traffic indicators” instruction in system prompt + no turn cap + 4–6 competitor target.
Adapter Config
Set in setup.worker.ts for the competitor-researcher role:
{
cwd,
model, // from AgentConfig.model
dangerouslySkipPermissions: true,
timeoutSec: 900,
maxTurnsPerRun: 20, // hard cap added April 2026
}Error Handling
| Error | Response |
|---|---|
| Competitor domain returns 404 or blocks scraping | Agent skips that competitor and continues with remaining |
| Fewer than 2 competitors researched | Output still passed to Context File Writer; no HITL gate |
| Max turns reached (20) | BullMQ job fails with “Reached maximum turns per run”; setup chain retries per BullMQ config |
enableCompetitorResearch = false | Chain skips this agent; Context File Writer receives a placeholder string |
Tenant Settings Used
| Setting | How it’s used |
|---|---|
contextConfig.enableCompetitorResearch | If false, agent is skipped entirely |
tenantName | Used in job display names and as the client to exclude from competitor searches |
country | Passed in prompt to focus geographic relevance |
plan | Passed in prompt to frame analysis depth |