Patterns
Part of Ai workflow automation. Install the skill and your agent reads this page when it needs the depth.
AI Workflow Automation
Patterns
Name
The Content Pipeline Architecture
Description
Standard workflow for AI-powered content production
When
Building automated content generation systems
Example
CONTENT PIPELINE STAGES:
STAGE 1: INPUT COLLECTION
├── Content requests (form, API, scheduled)
├── Brief validation (required fields check)
├── Variable extraction (audience, topic, format)
└── Trigger conditions met → Proceed to generation
STAGE 2: AI GENERATION
├── Prompt assembly (template + variables)
├── AI generation call (with retry logic)
├── Output capture and logging
├── Token usage tracking (cost monitoring)
└── Success check → Proceed to quality gates
STAGE 3: QUALITY GATES
├── Automated checks:
│ ├── Character count validation
│ ├── Required elements present
│ ├── Brand term usage check
│ ├── Prohibited terms check
│ └── Link/CTA validation
├── Pass/fail decision
├── Fail → Regenerate (max 3 attempts)
└── Pass → Proceed to approval
STAGE 4: APPROVAL WORKFLOW
├── Route based on content type:
│ ├── Low risk → Auto-approve
│ ├── Medium risk → Single reviewer
│ └── High risk → Multi-step approval
├── Notification to reviewers
├── Review deadline tracking
├── Escalation if no response
└── Approved → Proceed to distribution
STAGE 5: DISTRIBUTION
├── Format for each channel
├── Schedule or publish immediately
├── Confirm publication success
├── Log published content
└── Monitor performance (if applicable)
STAGE 6: MONITORING & LEARNING
├── Track success metrics
├── Log any failures or edits
├── Identify improvement patterns
└── Update prompts/rules based on learnings
CRITICAL DESIGN ELEMENTS:
- Every stage has failure handling
- All decisions are logged
- Human override always available
- Costs tracked at each AI call
- Quality gates prevent bad content from flowing
Name
Approval Workflow Design
Description
Human oversight without becoming bottleneck
When
Designing approval processes for automated content
Example
APPROVAL WORKFLOW TIERS:
TIER 1: AUTO-APPROVE (no human review)
Content types:
- Social media variations (tested template)
- Blog post variations (proven format)
- Email subject line tests (low risk)
Requirements:
□ Passes all automated quality gates
□ Uses approved templates
□ Low visibility/spend
□ Easy to edit post-publish
TIER 2: SINGLE REVIEWER (one human check)
Content types:
- New blog posts
- Standard email campaigns
- Social content (new topics)
- Ad variations (tested format)
Requirements:
□ One designated reviewer
□ 24-hour turnaround SLA
□ Approve/reject/edit powers
□ Auto-escalate if no response
Workflow:
1. Content generated
2. Slack/email notification to reviewer
3. Review link (in-context editing)
4. One-click approve/reject
5. Auto-publish on approval
TIER 3: MULTI-STEP APPROVAL (multiple stakeholders)
Content types:
- High-spend ad campaigns
- Legal-sensitive content
- C-suite communications
- Brand positioning content
Requirements:
□ Sequential or parallel approvals
□ Each stakeholder has 48-hour SLA
□ Comments collected centrally
□ Final approver has override authority
Workflow:
1. Content generated
2. First approver notified (e.g., marketing)
3. Upon approval → Second approver (e.g., legal)
4. Upon approval → Final approver (e.g., VP)
5. Manual publish (no auto-publish for highest risk)
APPROVAL FLOW DESIGN PATTERNS:
PARALLEL APPROVAL (faster):
Legal + Marketing + Brand review simultaneously
→ Consolidate feedback → Creator revises → Re-review
SEQUENTIAL APPROVAL (cleaner):
Creator → Marketing → Legal → Final
→ Each gate must pass before next
CONDITIONAL APPROVAL:
IF (content contains claims) → Legal required
IF (spend > $10k) → VP approval required
IF (new audience) → Strategy review required
ANTI-BOTTLENECK MEASURES:
- Auto-escalate: No response in SLA → notify manager
- Delegate: Approver can delegate to backup
- Emergency override: Senior leader can force-approve
- Batch approval: Review 10 similar items at once
- Template approval: Approve template once, variations auto-approve
Name
Multi-Channel Distribution Automation
Description
Publish content across channels automatically
When
Automating content distribution to multiple platforms
Example
MULTI-CHANNEL DISTRIBUTION SYSTEM:
CHANNEL REGISTRY:
Each channel defined with:
- Platform (LinkedIn, Twitter, Blog, Email)
- API credentials (secure vault)
- Formatting requirements
- Publishing schedule rules
- Success criteria
CONTENT ADAPTATION PIPELINE:
1. SOURCE CONTENT APPROVED
→ Single approved content piece
2. CHANNEL ADAPTATION
For each target channel:
├── Extract channel requirements
├── Adapt format:
│ ├── LinkedIn: Professional tone, 150-char hook
│ ├── Twitter: Casual tone, 280-char thread
│ ├── Blog: Full format, SEO optimization
│ └── Email: Subject line + preview + CTA
├── Generate platform-specific version
└── Validate against channel rules
3. SCHEDULING
├── Check channel-specific best times
├── Avoid conflicts (no double-posting)
├── Respect frequency limits
└── Queue for publication
4. PUBLISHING
├── API call to platform
├── Retry logic (3 attempts)
├── Success verification
├── Capture published URL
└── Log publication event
5. MONITORING
├── Track engagement (if API available)
├── Alert on errors or low performance
└── Feed data back to content system
EXAMPLE WORKFLOW:
INPUT: Blog post approved
"10 Ways to Improve Developer Productivity"
OUTPUT CHANNELS:
1. WordPress Blog:
- Full post with images
- SEO meta tags
- Schema markup
- Publish immediately
2. LinkedIn:
- Hook: "Just published: 10 dev productivity hacks"
- Summary: Key points (150 chars)
- Link to blog
- Image: Featured image from post
- Schedule: Tuesday 10am (best time)
3. Twitter Thread:
- Thread: 11 tweets (intro + 10 tips + CTA)
- Casual tone conversion
- Hashtags: #DevProductivity #Coding
- Schedule: Tuesday 2pm (after LinkedIn)
4. Email Newsletter:
- Subject: "10 Ways to Improve Developer Productivity"
- Preview text: First tip as teaser
- Body: Summary + "Read more" CTA
- Segment: Developers list
- Schedule: Wednesday 9am (batch send)
5. Slack Community:
- Message: "New post in #resources"
- Preview: First 2 tips
- Link to full post
- Schedule: Wednesday 11am
DISTRIBUTION RULES ENGINE:
Rule: IF (content type = blog post) AND (category = technical)
THEN publish to: [WordPress, LinkedIn, Twitter, Dev.to, Email]
Rule: IF (content type = product update)
THEN publish to: [Blog, LinkedIn, Twitter, Email, In-app]
Rule: IF (content type = thought leadership)
THEN publish to: [Blog, LinkedIn, Medium]
CRITICAL SAFEGUARDS:
- Preview before publish (human can review queue)
- Rate limiting (don't spam any channel)
- Error alerts (failed publish → immediate notification)
- Rollback capability (unpublish if needed)
- Analytics integration (track what works)
Name
Quality Gate Implementation
Description
Automated checks that prevent bad content from publishing
When
Building quality assurance into workflows
Example
QUALITY GATE SYSTEM:
GATE 1: TECHNICAL VALIDATION
Automated checks before AI generation:
□ Required fields present
□ Variable formats valid
□ Target channel specified
□ Budget limits not exceeded
GATE 2: OUTPUT VALIDATION
Automated checks after AI generation:
□ Content generated (not empty)
□ Minimum length met
□ Maximum length not exceeded
□ No generation errors logged
□ Token usage within limits
GATE 3: BRAND COMPLIANCE
Automated pattern matching:
□ Brand terms used (e.g., "our platform" vs competitor terms)
□ Prohibited terms absent (blacklist check)
□ Tone indicators present (e.g., professional vs casual)
□ Legal disclaimers included (if required)
Example brand compliance check:
```
REQUIRED TERMS (at least one):
- [Product Name]
- [Company Name]
- Our platform
PROHIBITED TERMS (none allowed):
- [Competitor names]
- Guaranteed results
- 100% success
- Free forever
TONE CHECK:
IF (channel = enterprise blog)
THEN require: [professional, data-driven, authoritative]
THEN prohibit: [emojis, slang, overly casual]
```
GATE 4: CONTENT QUALITY
Automated analysis:
□ Readability score (Flesch-Kincaid)
□ Sentiment analysis (positive/negative/neutral)
□ No repeated phrases (variation check)
□ CTA present and clear
□ Links functional (if applicable)
Example quality check:
```
READABILITY:
- Flesch score > 60 (accessible)
- Sentences < 20 words average
- Paragraphs < 5 sentences
CTA CHECK:
- Exactly 1 primary CTA
- CTA in first or last 20%
- CTA is action-oriented verb
DUPLICATION:
- Not >80% similar to previous content
- No 3+ word phrases repeated in same piece
```
GATE 5: PLATFORM COMPLIANCE
Channel-specific validation:
□ Character limits met
□ Image dimensions correct (if image)
□ Required fields populated
□ Format matches platform requirements
Example platform checks:
```
LINKEDIN:
- Post length: 150-3000 chars ✓
- First line < 150 chars (before "see more") ✓
- Image: 1200x627 (if image) ✓
- Hashtags: 3-5 recommended ✓
TWITTER:
- Tweet length: < 280 chars ✓
- Thread: < 25 tweets ✓
- Image: 1200x675 (if image) ✓
- No banned words ✓
EMAIL:
- Subject: 30-50 chars ✓
- Preview text: present ✓
- Unsubscribe link: present ✓
- No spam trigger words ✓
```
FAILURE HANDLING:
SOFT FAIL (warning, but proceed):
- Readability slightly low
- Hashtag count suboptimal
- Minor formatting suggestion
HARD FAIL (block publication):
- Prohibited terms present
- Character limit exceeded
- Required CTA missing
- Brand terms absent
HARD FAIL ACTIONS:
1. Log failure reason
2. Notify creator/reviewer
3. Attempt auto-regenerate (if possible)
4. If auto-fix fails → Human review required
MONITORING & IMPROVEMENT:
- Track gate pass/fail rates
- Identify common failures
- Update prompts to pass gates
- Refine gate thresholds over time
Name
Human-in-the-Loop Pattern
Description
Strategic human judgment within automated workflows
When
Determining where humans add value in automation
Example
HUMAN-IN-THE-LOOP DECISION FRAMEWORK:
AUTOMATE COMPLETELY (0% human):
Tasks where AI + rules are sufficient:
- Content formatting for platforms
- Scheduled publishing
- Performance data collection
- Routine social media replies
- Template population
- Character count adjustments
Requirements for full automation:
- Low risk (easy to undo)
- High repeatability (same every time)
- Clear rules (no judgment needed)
- Fast feedback (know quickly if wrong)
HUMAN REVIEW (100% human):
Tasks requiring human judgment:
- Strategic decisions (what to prioritize)
- Creative direction (brand voice evolution)
- Sensitive topics (PR, legal, crisis)
- Stakeholder communications
- High-spend campaign approval
- New message testing
Requirements for human review:
- High risk (expensive mistakes)
- Nuanced judgment (context-dependent)
- Brand impact (affects perception)
- Slow feedback (delayed consequences)
HUMAN-IN-THE-LOOP (selective human):
AI generates, human decides when to intervene:
TRIGGER-BASED INTERVENTION:
Automation runs unless:
- Confidence score < threshold
- Flagged by quality gates
- High-value opportunity
- Anomaly detected
Example implementation:
```
WORKFLOW: AI writes social posts
AUTOMATION RULE:
IF (topic = routine product update)
AND (all quality gates pass)
AND (similar posts performed well)
THEN auto-publish
HUMAN REVIEW TRIGGERED IF:
- Topic = new/sensitive
- Quality gate fails
- Readability score < 60
- Sentiment = negative
- Mentions competitors
- Contains pricing/legal claims
WHEN TRIGGERED:
1. Pause workflow
2. Notify reviewer (Slack)
3. Present content + flag reason
4. Reviewer: Approve / Edit / Reject
5. Resume workflow
```
SAMPLING-BASED REVIEW:
Human reviews random sample to audit quality:
Example: Email campaign automation
- AI generates 100 personalized emails
- Human reviews random 10 (10% sample)
- If >2 issues found → Review all
- If <2 issues → Approve batch
ESCALATION-BASED REVIEW:
Tiered approval based on risk:
Example: Ad spend threshold
- Spend < $500: Auto-publish
- Spend $500-$5k: Marketing review
- Spend > $5k: VP approval
FEEDBACK LOOP:
Humans improve automation over time:
1. AI generates content
2. Human edits before publish
3. System logs edits (what changed)
4. Pattern analysis on edits
5. Update prompts to reduce edits
6. Measure: edit rate should decrease
Example metrics:
- Month 1: 60% of AI content edited
- Month 3: 30% edited (prompts improved)
- Month 6: 10% edited (mostly edge cases)
- Goal: <5% edit rate
GRACEFUL DEGRADATION:
When humans unavailable, system adapts:
SCENARIO: Approver on vacation
Options:
1. Route to backup approver (preferred)
2. Lower-tier content: Auto-approve
3. Higher-tier content: Queue for return
4. Emergency: Escalate to manager
HUMAN WORKLOAD MANAGEMENT:
- Batch reviews (review 10 at once vs 10 interruptions)
- Priority queues (high-value first)
- Time-boxed sessions (15 min review blocks)
- Accept/reject shortcuts (keyboard hotkeys)
- Pre-filtered (only show items needing human judgment)
Name
Cost Tracking and Control
Description
Monitor and limit AI generation costs
When
Building workflows with AI API costs
Example
COST TRACKING ARCHITECTURE:
LEVEL 1: PER-REQUEST TRACKING
Every AI API call logs:
- Timestamp
- Model used (gpt-4, claude-3, etc)
- Input tokens
- Output tokens
- Total cost (calculated)
- Request type (generation, editing, etc)
- Success/failure
- User/project ID
Example log entry:
```json
{
"timestamp": "2025-12-25T10:30:00Z",
"model": "claude-3-sonnet",
"input_tokens": 1500,
"output_tokens": 800,
"cost_usd": 0.0234,
"request_type": "blog_generation",
"project": "content_automation",
"status": "success"
}
```
LEVEL 2: AGGREGATED MONITORING
Real-time dashboards showing:
- Cost per hour/day/month
- Cost by project
- Cost by model
- Cost by user
- Token usage trends
- Failed requests (wasted cost)
LEVEL 3: ALERTS AND LIMITS
Automated cost controls:
SOFT LIMITS (warnings):
- Daily spend > $100 → Slack alert
- Project spend > budget → Email to owner
- Unusual spike detected → Investigate notification
HARD LIMITS (circuit breakers):
- Daily spend > $500 → Pause all automation
- Per-request > $2 → Require approval
- Failed request rate > 10% → Stop and alert
Example limit configuration:
```yaml
cost_limits:
daily_budget: 500.00 # USD
monthly_budget: 10000.00
per_request_max: 2.00
alerts:
- threshold: 50% # of daily budget
action: slack_warning
- threshold: 80%
action: email_owner
- threshold: 100%
action: pause_workflows
per_project_limits:
blog_automation: 200.00/day
social_media: 100.00/day
email_campaigns: 150.00/day
```
COST OPTIMIZATION STRATEGIES:
1. MODEL SELECTION:
- Use cheapest model that meets quality bar
- GPT-3.5 for simple tasks
- Claude-3-Haiku for speed + cost
- GPT-4/Claude-3-Opus only when needed
2. PROMPT OPTIMIZATION:
- Shorter prompts where possible
- Remove unnecessary examples
- Use prompt caching (if available)
- Batch similar requests
3. OUTPUT LENGTH CONTROL:
- Set max_tokens appropriately
- Don't request 2000 tokens if 500 sufficient
- Use length-specific prompts
4. CACHING STRATEGY:
- Cache common generations
- Reuse similar content
- Check cache before API call
Example caching:
```
REQUEST: Generate social post about Product X launch
BEFORE CALLING API:
1. Check cache for "Product X launch social post"
2. If found (< 7 days old) → Use cached
3. If not found → Generate + cache
CACHE KEY: hash(prompt + model + params)
CACHE TTL: 7 days
CACHE INVALIDATION: Manual or on product update
```
5. FAILURE REDUCTION:
- Validate inputs before API call
- Don't waste tokens on bad requests
- Implement retry with backoff
- Log failures for pattern analysis
COST REPORTING:
Daily report (email/Slack):
```
AI Workflow Cost Report - Dec 25, 2025
Total Spend: $327.45 ($173 under budget)
By Project:
- Blog Automation: $145.20 (58 posts generated)
- Social Media: $82.15 (234 posts generated)
- Email Campaigns: $100.10 (15 campaigns)
Top Costs:
1. Long-form blog posts: $2.50/post avg
2. Email subject line testing: $0.15/test
3. Social media threads: $0.35/thread
Efficiency Metrics:
- Avg cost per generation: $0.87
- Failed requests: 2.3% (↓ from 4.1% yesterday)
- Cache hit rate: 18% (saved $73.20)
Recommendations:
- Consider switching blog posts to Claude (30% cheaper)
- Increase cache TTL for social posts
```
BUDGETING FOR AI WORKFLOWS:
Estimation framework:
1. Expected volume (posts/month)
2. Avg tokens per generation
3. Model costs (per 1M tokens)
4. Buffer for retries (add 15%)
5. Growth projection
Example budget:
```
Blog posts:
- 60 posts/month
- 2000 tokens/post average
- GPT-4: $30/1M tokens
- 60 * 2000 = 120k tokens
- Cost: $3.60/month
- With 15% buffer: $4.14/month
Social media:
- 300 posts/month
- 300 tokens/post
- GPT-3.5: $2/1M tokens
- 300 * 300 = 90k tokens
- Cost: $0.18/month
- With buffer: $0.21/month
Total estimated: $4.35/month
Actual budget (3x safety): $13/month
```
Name
Workflow Versioning and Documentation
Description
Maintain workflow history and documentation
When
Building production-grade automation systems
Example
WORKFLOW VERSION CONTROL:
Every workflow has:
- Version number (semantic: 1.2.3)
- Change log (what changed and why)
- Rollback capability
- Testing/staging environment
WORKFLOW MANIFEST:
```yaml
workflow: blog_post_automation
version: 2.3.1
created: 2025-01-15
last_modified: 2025-12-20
owner: marketing_team
status: production
changelog:
- version: 2.3.1
date: 2025-12-20
changes:
- "Added brand term validation gate"
- "Increased retry attempts from 2 to 3"
reason: "Reduce manual edit rate"
- version: 2.3.0
date: 2025-11-10
changes:
- "Added multi-step approval for high-value posts"
- "Integrated SEO optimization step"
reason: "Improve content quality and ranking"
- version: 2.2.0
date: 2025-09-05
changes:
- "Switched from GPT-4 to Claude-3 for cost savings"
- "Updated prompt templates"
reason: "Reduce costs by 30% while maintaining quality"
dependencies:
- service: claude_api
version: ">=3.0"
- service: wordpress_api
version: ">=5.0"
- service: slack_webhooks
version: "any"
config:
ai_model: claude-3-sonnet
max_retries: 3
approval_timeout: 48h
auto_publish: false
```
DOCUMENTATION STRUCTURE:
1. OVERVIEW:
- What: Purpose of workflow
- Why: Business value
- Who: Owners and stakeholders
- When: Trigger conditions
2. ARCHITECTURE DIAGRAM:
- Visual workflow (flowchart)
- Integration points
- Data flow
- Decision points
3. CONFIGURATION:
- Environment variables
- API credentials (reference, not values)
- Adjustable parameters
- Feature flags
4. OPERATIONAL RUNBOOK:
- How to trigger manually
- How to pause/resume
- How to monitor
- How to troubleshoot
5. QUALITY GATES:
- What gates exist
- Pass/fail criteria
- Failure handling
6. APPROVAL FLOWS:
- Who approves what
- Escalation paths
- SLAs
7. METRICS:
- Success criteria
- KPIs tracked
- Dashboard links
8. DISASTER RECOVERY:
- Rollback procedure
- Emergency contacts
- Known failure modes
TESTING WORKFLOW CHANGES:
STAGING ENVIRONMENT:
- Mirror of production
- Test with real APIs (dev accounts)
- Sample data (not production data)
TESTING CHECKLIST:
□ Happy path (everything works)
□ Quality gate failures
□ API errors (retry logic)
□ Timeout scenarios
□ Approval delays
□ Cost limit triggers
□ Concurrent requests
ROLLOUT STRATEGY:
1. CANARY DEPLOYMENT:
- Route 10% of traffic to new version
- Monitor for issues
- If stable → 50%
- If stable → 100%
2. FEATURE FLAGS:
```yaml
features:
new_approval_flow:
enabled: true
rollout_percentage: 25
rollback_on_error_rate: 5%
```
3. A/B TESTING:
- Run old and new workflow in parallel
- Compare quality metrics
- Choose winner based on data
MONITORING & ALERTS:
Track workflow health:
- Success rate (target: >95%)
- Average completion time
- Cost per execution
- Quality gate pass rate
- Approval turnaround time
- Error types and frequency
Example monitoring dashboard:
```
Blog Automation Workflow - v2.3.1
Status: Healthy ✓
Last 24 Hours:
- Executions: 58
- Success rate: 96.5% (56/58)
- Avg completion: 2.3 hours
- Avg cost: $2.45/post
- Manual edits: 8.6% (↓ from 12%)
Quality Gates:
- Brand compliance: 100% pass
- Readability: 94% pass
- Platform compliance: 100% pass
Approvals:
- Avg turnaround: 6.2 hours
- Timeout rate: 1.7%
Issues (last 24h):
- 1× WordPress API timeout (retried successfully)
- 1× Low readability score (human review approved)
```
CONTINUOUS IMPROVEMENT:
Monthly workflow review:
1. Analyze metrics
2. Identify bottlenecks
3. Propose optimizations
4. Test in staging
5. Deploy incrementally
6. Measure impact
Anti-Patterns
Name
Over-Automation Without Quality Gates
Description
Automating content generation without sufficient quality checks
Why
Speed without quality creates brand damage at scale
Instead
Build quality gates before scaling automation
Name
Brand Voice Drift
Description
Not monitoring consistency as AI generates at scale
Why
Automated content can gradually diverge from brand voice
Instead
Regular brand compliance audits and prompt refinement
Name
No Cost Monitoring
Description
Running AI workflows without tracking expenses
Why
Costs can spiral quickly with high-volume automation
Instead
Implement cost tracking and limits from day one
Name
Single Point of Approval Bottleneck
Description
One person must approve all automated content
Why
Creates delays that negate automation benefits
Instead
Tiered approval with delegation and auto-approval for low-risk
Name
Ignoring Failure Patterns
Description
Not analyzing why workflows fail or require manual intervention
Why
Same issues repeat, wasting time and reducing trust
Instead
Log all failures, analyze patterns, update workflows
Name
No Human Override Path
Description
Automation locks out human intervention
Why
Edge cases and emergencies require human judgment
Instead
Always provide manual override and emergency stop