# OpenClaw Implementation Prompts Each prompt below is a self-contained brief you can hand to an AI coding assistant (or use as a project spec) to build that use case from scratch. Adapt the specific services to whatever you already use — the patterns are what matter. --- ## 1) Personal CRM Intelligence ``` Build me a personal CRM system that automatically tracks everyone I interact with, with smart filtering so it only adds real people — not newsletters, bots, or cold outreach. Data sources: - Connect to my email (Gmail API or IMAP) and scan the last 60 days of messages. - Connect to my calendar (Google Calendar API) and scan the last 60 days of events. - Run this ingestion on a daily cron schedule. Contact extraction from email: - Extract sender/recipient email addresses and names from messages. - Estimate the number of exchanges (back-and-forth threads, not just raw message count): Math.min(Math.floor(totalMessages / 2), threadCount). - Collect sample subject lines and message snippets for classification. Contact extraction from calendar: - Only include meetings with 1-10 attendees (skip large all-hands). - Only include meetings at least 15 minutes long (skip quick check-ins that are really just reminders). - Extract attendee names, emails, and the meeting title. Filtering — this is critical. Most contacts from email are noise. Use a two-stage filter: Stage 1 — Hard filters (always reject): - My own email addresses and domains. - Emails from family or personal contacts I've explicitly excluded (configurable list). - Contacts already in the CRM or previously rejected. - Generic role-based inboxes: info@, team@, partnerships@, collabs@, noreply@. - Marketing/transactional domains matching patterns like: noreply@, tx., cx., mail., email. prefixes. Stage 2 — AI classification (use a fast, cheap LLM like Gemini Flash or Haiku): Send the candidate's name, email, exchange count, and sample subject lines/snippets to an LLM with these rules: - REJECT clearly automated or notification-only senders. - REJECT if all sample subjects look like newsletters, digests, or automated reports ("weekly roundup", "monthly update", "AI news"). - REJECT cold outreach with low engagement — if exchanges are low relative to total emails, it's one-way pitching. - REJECT if snippets show repetitive promotional content (product launches, feature announcements, affiliate reports). - APPROVE only if it looks like a real person with genuine two-way interaction or a meaningful business relationship. - Higher confidence for real back-and-forth conversations with varied, substantive topics. Contact scoring (used for ranking, not filtering): - Base score: 50 - +5 per email exchange (max +20) - +3 per meeting (max +15) - +15 if their title matches preferred titles (CEO, Founder, VP, Head of, Engineer, Partner, etc.) - +10 if they appeared in small meetings (≤3 attendees) - +10 if last interaction was within 7 days, +5 if within 30 days - +25 bonus if the person appears in both email AND calendar (stronger signal) - +10 if they have a recognizable role, +5 if they have a company For each approved contact, store: - Name, email(s), company, role/context - Interaction timeline with dates - Last-touch timestamp (auto-updated) - Contact score - Tags or categories Learning system: - Maintain a learning.json config with: - skip_domains: domains to always reject (populated over time from rejections) - prefer_titles: titles that boost contact scores - skip_keywords: subject-line keywords that indicate spam - min_exchanges: minimum exchange threshold (default 1) - max_days_between: max days since last interaction (default 60) - max_attendees: meeting size cap (default 10) - min_duration_minutes: meeting length minimum (default 15) - When I reject a contact, learn from it — add their domain to skip_domains if appropriate. Deduplication: - When a new contact is found, check by email, then by name+company combination. - Merge records rather than creating duplicates. Semantic retrieval: - Generate embeddings for each contact record. - Let me ask natural-language questions like: - "Who did I meet from [company] last month?" - "When did I last talk to [name]?" - "Show contacts I haven't spoken to in 30+ days." Storage: SQLite with WAL mode and foreign keys enabled. Notifications: After each ingestion run, send a summary of new contacts, merges, rejections, and any issues. ``` --- ## 2) Knowledge Base (RAG) — Save Anything, Recall It Later ``` Build me a personal knowledge base with RAG (retrieval-augmented generation). Ingestion — I send a URL or file and the system saves it. It should handle: - Web articles - YouTube videos (transcripts) - Tweets/X posts - PDFs - Plain text or notes Source type detection: Determine the type from the URL pattern or file extension. Classify as: article, video, pdf, text, tweet, or other. Content extraction with fallback chain — this is important because no single extractor works for every site: 1. For Twitter/X URLs: a. Try FxTwitter API (api.fxtwitter.com) — free, no auth needed b. Fall back to X API direct lookup c. Fall back to web scraping 2. For YouTube URLs: a. Pull transcript via YouTube transcript API or yt-dlp 3. For all other URLs (articles, blogs, etc.): a. Try a clean text extractor (like Mozilla Readability or similar) b. Fall back to Firecrawl or Apify for sites that block simple extraction c. Fall back to a headless browser (Playwright/Puppeteer) for JavaScript-heavy pages d. Last resort: raw HTTP fetch + HTML tag stripping - Retry once on transient errors (ECONNRESET, ETIMEDOUT, DNS failures) with a 2-second delay. Content quality validation — reject bad extractions: - Minimum 20 characters of content. - For articles/non-tweets: at least 15% of non-empty lines must be longer than 80 characters (to detect prose vs. navigation menus). - Total content must be at least 500 characters for non-tweet types. - Detect error pages by looking for 2+ signals: "access denied", "captcha", "please enable javascript", "cloudflare", "404", "sign in", "blocked", "rate limit". - Maximum content length: 200,000 characters (truncate beyond this). Deduplication — two layers: 1. URL-based: Normalize URLs before comparing — strip tracking params (utm_source, utm_medium, utm_campaign, fbclid, igshid, ref, s, t), remove www., normalize twitter.com to x.com, remove trailing slashes and fragments. 2. Content-hash: SHA-256 hash of the cleaned content. Store as a UNIQUE column — reject if the same hash already exists. Chunking: - Chunk size: 800 characters per chunk. - Overlap: 200 characters between chunks. - Minimum chunk size: 100 characters (append tiny remainders to the last chunk). - Split on sentence boundaries (regex: /(?<=[.!?])\s+/). Embedding generation: - Use Google gemini-embedding-001 (768 dimensions, free) or OpenAI text-embedding-3-small (1536 dimensions) as fallback. - Max input: 8000 characters per chunk. - Process in batches of 10 chunks with 200ms delay between batches. - Retry failed embeddings 3 times with exponential backoff (1s, 2s, 4s). - Cache embeddings with an LRU cache (1000 entries). Storage — SQLite with two tables: - sources: id, url, title, source_type, summary, raw_content, content_hash (UNIQUE), tags (JSON array), created_at, updated_at - chunks: id, source_id (FK), chunk_index, content, embedding (BLOB), embedding_dim, embedding_provider, embedding_model, created_at - Index on chunks(source_id), sources(source_type), sources(content_hash). - Enable WAL mode and foreign keys with CASCADE deletes. Concurrency protection: Use a lock file to prevent simultaneous ingestion runs. Check if lock is stale (PID dead or file older than 15 minutes). Retrieval — When I ask a question: 1. Embed my query using the same embedding provider. 2. Cosine similarity search over all stored chunks. Return top 10. 3. Deduplicate results: keep only the best chunk per source. 4. Sanitize content in results (max 2500 characters per excerpt). 5. Pass top chunks to an LLM: "Answer using only the provided context. Cite which sources you drew from." 6. Return the answer with source references. ``` --- ## 3) Content Idea Pipeline (Research → Dedupe → Project Management) ``` Build a content idea pipeline that researches topics, prevents duplicate ideas, and creates production-ready tasks. Trigger: I describe a topic idea in chat. Step 1 — Research: - Search X/Twitter for recent discourse on the topic (use the tiered approach from Use Case #4 if built). - Search my knowledge base (Use Case #2) for related saved content. - Optionally run a web search. Step 2 — Semantic dedupe (this is the critical gate): - Maintain a database of all past content ideas with these fields: - id (format: YYYY-MM-DD-NNN) - date, type (short/long-form), title, slug (URL-friendly, UNIQUE) - summary (the pitch text) - tags (comma-separated) - status: pitched, accepted, rejected, produced, duplicate - response (my feedback) - embedding (BLOB — generated via Gemini or OpenAI) - created_at - When a new idea comes in, run a hybrid similarity search: - Semantic similarity (70% weight): Cosine similarity between the new idea's embedding and all stored embeddings. - Keyword matching (30% weight): Match against title (30%), summary (20%), and tags (20%). - Combined score: (semantic × 0.7) + (keyword × 0.3) - Hard gate: If any existing idea scores above 40% combined similarity, REJECT the new idea. Show me what it matched and the similarity score. No exceptions — this prevents re-pitching old concepts. Step 3 — Brief assembly (only if it passes dedupe): - Keep it short — a few sentences on the angle and why it's video-worthy. - Do NOT generate titles, thumbnails, hooks, or scripts unless I explicitly ask. - Include links to relevant tweets or KB sources from the research step. Step 4 — Create task: - Create a task in my project management tool (Asana, Linear, Notion, or Todoist) with the brief as the description. Step 5 — Store the idea: - Add the new idea + its embedding to the pitch database so future ideas are compared against it. - Set initial status to "pitched". Step 6 — Notify me with the brief and a link to the created task. ``` --- ## 4) Social Media Research System (Cost-Optimized) ``` Build a social media research tool that answers "What are people saying about [topic]?" using X/Twitter, while minimizing API costs. Query decomposition: - Take my question and break it into 2-4 focused search queries covering different angles. Tiered retrieval — always try the cheapest option first: - Tier 1 (free): FxTwitter API (api.fxtwitter.com) — works for individual tweet lookups, no auth needed. - Tier 2 (low-cost, ~$0.15/1K tweets): A paid Twitter data provider like TwitterAPI.io or SocialData. Supports search, profiles, user tweets, and thread context. - Tier 3 (expensive, ~$0.005/tweet): Official X API v2 (api.x.com/2). Last resort only. Rate limit to 350ms between requests to stay under 450 req/15min. How the tiers cascade by operation: - Single tweet lookup: Tier 1 → Tier 2 → Tier 3 - Search: Tier 2 → Tier 3 - Profile lookup: Tier 2 → Tier 3 - Thread expansion: Tier 2 → Tier 3 Filtering: - Filter by timeframe (default: last 7 days, configurable). - Rank by engagement (likes + retweets + replies). - Remove retweets and duplicate content. - Suppress low-quality or spam results. Thread expansion: For high-engagement tweets that are part of a thread, pull the full thread. Caching: Cache results with a 1-hour TTL so repeated queries don't burn API credits. Usage logging: Log every API call to a separate log file per tier, with timestamps and estimated costs. Output — synthesize into a briefing: - Key narratives: 3-5 dominant takes - Notable posts: 5-10 most relevant tweets with links - Sentiment summary: positive, negative, or mixed - Contrarian takes: interesting minority opinions ``` --- ## 5) YouTube Analytics + Competitor Tracking ``` Build a YouTube analytics system that tracks my channel daily and monitors competitors. My channel — collect these metrics daily via YouTube Data API and YouTube Analytics API: - views (total and per-video) - estimatedMinutesWatched (watch time) - averageViewDuration - subscribersGained - impressions and CTR (if available via Analytics API) Store each day's metrics in a SQLite table: - daily_stats: video_id, date, views, watch_time_minutes, avg_view_duration, impressions, ctr, subscribers_gained - videos: id, title, published_at, thumbnail_url, duration_seconds Derived metrics: - 7-day moving average for daily views - Subscriber-to-view conversion rate - Views-per-video trend Competitor tracking: - Accept a configurable list of competitor channel IDs/usernames. - Daily, pull each competitor's recent uploads (title, publish date, views) and subscriber count via YouTube Data API. - Track upload cadence and momentum. Chart generation — produce PNG charts using matplotlib (dark theme): 1. "trend" chart: Daily view trend for a specific video (line chart with fill area) 2. "top" chart: Top N videos by views (horizontal bar chart, color-coded by short vs long-form) 3. "daily" chart: Channel-wide daily views with 7-day moving average overlay - Format numbers with commas, dates as readable labels, include grid and legends. - Save charts to a designated output folder. Schedule: Daily cron job collecting all data. Optional daily summary sent to chat. ``` --- ## 6) Nightly Business Briefing (Multi-Perspective AI Council) ``` Build a nightly business analysis system that collects signals from across my tools and produces prioritized recommendations using a multi-persona AI review council. Signal collection — pull data from whatever systems you use. Normalize each signal into: { source, signal_name, value, confidence (0-100), direction (up/down/flat), category } Example sources: YouTube metrics, CRM health, project management backlog, social growth, email themes, meeting action items, sales pipeline, operations/cron reliability. Compact to the top 200 signals by confidence score, with up to 4 sample events per source. Three-phase AI review council (all phases use a frontier model like Claude Opus or GPT-4): Phase 1 — Draft (LeadAnalyst): - Score business outlook on weekly and monthly horizons (0-100), plus a blended average. - Generate 5-10 recommendations, each with: title, description (2-3 plain sentences), evidence references, estimated impact (0-100), estimated effort (0-100), confidence (0-100). - Constraints: use only provided data, no made-up facts, plain human language, don't recommend publishing content immediately. Phase 2 — Parallel review (4 personas, run simultaneously via Promise.all): 1. GrowthStrategist: Scalable growth, asymmetric upside. Demands concrete evidence. 2. RevenueGuardian: Near-term revenue and cash flow. Challenges anything that doesn't protect income. 3. SkepticalOperator: Execution reality, data quality risks. Challenges weak assumptions. 4. TeamDynamicsArchitect: Team health, collaboration quality, sustainable pace. Each reviewer: - Critiques every recommendation: support, revise, or reject (with score adjustments) - Can propose new recommendations the draft missed - Returns: reviewer_name, key_findings[], votes[] (with adjusted scores), new_recommendations[] Phase 3 — Consensus (CouncilModerator): - Receives draft + all 4 reviews. - Reconciles disagreements. - Produces final recommendation set with consensus notes. Fallback: If consensus fails, use draft recommendations. If a reviewer fails, substitute a stub review with the error message. Ranking — score each recommendation: priority = (impact × w1) + (confidence × w2) + ((100 - effort) × w3) Default weights: w1=0.4, w2=0.35, w3=0.25. Store weights in a policy table and update via feedback over time. Filter: Remove any "publish now" recommendations (hard constraint). Output: Deliver ranked recommendations to my preferred channel. Store full council trace (draft, all reviews, consensus, models used) in a database for auditing and backtesting. Schedule: Run nightly via cron. ``` --- ## 7) CRM/Business Tool Natural Language Access ``` Build a natural-language interface to my CRM (HubSpot, Salesforce, or whatever I use). Supported objects and operations: - Contacts: search, create, update, list, get by ID - Companies: search, create, update, list - Deals: search, create, update, list, query by pipeline stage - Owners: list - Associations: link contacts to companies, deals to contacts, deals to companies (For HubSpot, common association type IDs: 1=Contact→Company, 3=Deal→Contact, 5=Deal→Company) - Properties/schema: inspect available fields for any object Intent classification — parse my message into: 1. Lookup: "Find the contact for [name]" → search contacts 2. Create: "Add a new contact: [name], [email], [company]" → create contact 3. Update: "Update [contact]'s title to [new title]" → update contact 4. List: "Show all deals in negotiation stage" → filter deals 5. Associate: "Link [contact] to [company]" → create association Validation: If I'm missing required fields, ask me before proceeding. Response format: Return clean, readable summaries — not raw JSON. For deal queries, include: deal name, amount, stage, close date, last modified. Authentication: API key or OAuth stored in environment variables. ``` --- ## 8) AI Content Humanization ``` Build a text rewriting tool that removes AI-generated artifacts and makes content sound like a real person wrote it. Input: I paste draft text (social posts, blog paragraphs, emails, video scripts). Step 1 — Detection. Scan for common AI tells: - Overuse of: "delve", "landscape", "leverage", "it's important to note", "in conclusion", "game-changing", "revolutionary", "transformative" - Tone inflation: dramatic language when the subject doesn't warrant it - Generic phrasing that could apply to any topic - Repetitive sentence structures (every sentence starting the same way) - Excessive hedging: "It's worth noting that perhaps..." - Lists that feel generated (too clean, too parallel, no personality) - Identical paragraph lengths and rhythms Step 2 — Rewrite: - Replace vague qualifiers with specific, concrete language - Vary sentence length (mix short punchy sentences with longer ones) - Use contractions, sentence fragments, and informal word choices where natural - Remove filler while keeping the core message - Add the kind of imperfections real writing has — not errors, but human cadence Step 3 — Channel tuning (optional, based on destination): - Twitter/X: Punchy, under 280 chars, direct, no filler - LinkedIn: Professional but conversational, authoritative without being stiff - Blog: Longer form, personal anecdotes and opinions welcome - Email: Brief, clear, action-oriented, warm but efficient Output: Return the revised text. Optionally highlight what changed and why. ``` --- ## 9) Image Generation + Iterative Editing ``` Build an image generation workflow where I describe what I need in chat and iterate until it's right. Core flow: 1. I describe an image: subject, style, composition, mood, colors, any text to include. 2. Generate 1-3 variants using an image generation API (DALL-E 3, Midjourney API, Stable Diffusion, or Flux). 3. I review and either: a. Accept → save as final asset b. Request changes → I describe adjustments ("darker background", "remove text", "more minimal") and it generates new variants incorporating my feedback 4. Loop continues until I'm satisfied. Image editing: - I can send an existing image and ask for edits: swap background, adjust composition, combine multiple images. - Use inpainting or img2img when available. Context tracking: Remember what we've been working on across multiple messages in the same session so I don't have to re-describe the whole concept each iteration. Output: Save final assets to a designated folder. Deliver as downloadable files in chat. ``` --- ## 10) Task Management from Meetings + Chat ``` Build a system that extracts action items from meetings and conversations, gets my approval, then creates tasks in my task manager. Input sources: - Meeting transcripts from Fathom, Otter.ai, Fireflies, or any transcript provider - Notes I paste into chat - Direct commands: "Add a task to follow up with [person] by Friday" Extraction — use an LLM (Gemini Flash or similar fast model) to parse transcripts and extract: - description: what needs to be done (max 150 characters, clear and actionable) - assignee: who is responsible (name as it appears in the transcript) - is_owner: boolean — is this MY action item or someone else's? - todoist_title: clean task title (max 120 chars) — only generate this for items where is_owner is true - Do NOT extract vague items like "think about X" — only concrete actions with a clear next step. CRM cross-reference (if you have Use Case #1 built): - Match mentioned people against CRM contacts to enrich with company/role context. Approval flow — this is important, don't auto-create tasks: 1. Show me the extracted task list with each item numbered. 2. Let me choose: "all", "none", or specific items by number (e.g. "1, 3, 5"). 3. Let me edit any task before confirming (change title, priority, due date). 4. Only after I approve, create the tasks via the Todoist/Asana/Linear API. 5. If any task creation fails, keep it in a pending state for retry. Direct task creation: - When I say "remind me to [thing] by [date]", skip extraction and create directly after confirming. Output: Send confirmation with links to created tasks. Persist approval state so I can check what's pending. Default project: Configure a default project/list for tasks (e.g. "Work" or my company name). ``` --- ## 11) AI Usage and Cost Tracking ``` Build a logging and reporting system that tracks every AI API call and provides cost visibility. Logging — wrap every LLM/AI API call with a logger that records this structure (one JSON object per line in a JSONL file): { "timestamp": "ISO8601", "model": "model-name", "tokens": { "input": number, "output": number, "total": number }, "taskType": "string (e.g. crm-ingestion, x-research, image-gen, business-analysis)", "description": "string (brief note on what this call was for)", "costEstimate": number, "source": "tracker-name" } Cost calculation — use a pricing lookup table (per 1M tokens, input/output): - Anthropic: Opus ($15/$75), Sonnet ($3/$15), Haiku ($0.80/$4) - OpenAI: GPT-4 ($30/$60), GPT-4 Turbo ($10/$30), GPT-3.5 Turbo ($0.50/$1.50), o1 ($15/$60) - Google: Gemini Pro ($10/$30), Gemini Flash ($0.30/$1.20), Gemini 1.5 Pro ($1.25/$5) - xAI: Grok ($2/$10) - Default for unknown models: $1/$3 - Formula: (inputTokens / 1M) × inputPrice + (outputTokens / 1M) × outputPrice - Keep this table in a config file so it's easy to update when pricing changes. Storage: Append-only JSONL file. Optionally mirror to SQLite for faster querying. Reporting — generate on demand with filters (--days N, --model X, --task-type Y): 1. Overall summary: total calls, total tokens (input/output/total), total cost 2. By model: calls, tokens, cost — sorted by cost descending 3. By task type: calls, tokens, cost — sorted by cost descending 4. By day: last 10 days showing calls, tokens, and cost per day 5. Trend: daily or weekly spending over the last 30/90 days Routing suggestions: - Flag any task type where a frontier model (Opus, GPT-4) is being used but the task is simple (short inputs, formatting-only, data extraction) — suggest downgrading to a cheaper model. - Flag workflows that account for >25% of total spend as optimization candidates. - Suggest caching strategies for repeated queries (especially research workflows). Output: Markdown report or simple web dashboard. Optionally send weekly cost summary to my chat. ```