Skip to main content

apify-market-research

Implements intelligent apify market research with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense

설치로 이동

소스 정보

저장소
paulpas/agent-skill-router
최근 소스 활동
2026년 6월 4일 23:31
감지된 SKILL.md 언어
영어
스타
6
포크
0

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
apify-market-research
compatibility
opencode
completeness
95
content-types
["guidance","examples","do-dont"]
description
Implements intelligent apify market research with multi-factor skill selection, fallback chains, and adherence to the 5 Laws of Elegant Defense
license
MIT
maturity
stable
metadata
{"domain":"agent","output-format":"analysis","related-skills":"agent-confidence-based-selector, agent-task-routing","role":"orchestration","scope":"orchestration","triggers":"apify-market-research, apify market research, how do i apify-market-research, orchestrate apify-market-research, automate apify-market-research, agent apify-market-research","archetypes":["orchestration","strategic"],"anti_triggers":["brainstorming","vague ideation","single-agent monolith"],"response_profile":{"verbosity":"medium","directive_strength":"high","abstraction_level":"tactical"}}
version
1.0.0
# Apify Market Research Orchestrates intelligent skill selection and execution for apify market research workflows. Applies the 5 Laws of Elegant Defense to guide data naturally through the orchestration pipeline, preventing errors before they occur. Selects optimal skills based on multi-factor scoring including text similarity, historical performance, and system availability. ## TL;DR Checklist - [ ] Parse all inputs at boundary before processing (Law 2) - [ ] Handle edge cases with early returns at function top (Law 1) - [ ] Fail immediately with descriptive errors on invalid states (Law 4) - [ ] Return new data structures, never mutate inputs (Law 3) - [ ] Implement minimum 2-level fallback chain for all skill executions - [ ] Log all skill selections with context for full audit trail - [ ] Validate skill metadata and dependencies before selection - [ ] Update confidence scores after each execution for learning ┌───────────────────────────────────────────────────────────────────────────────┐ │ Orchestration Flow │ └───────────────────────────────────────────────────────────────────────────────┘ User Request ↓ ┌─────────────────┐ │ Parse Request │ │ & Extract │ │ Features │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Evaluate Available Skills │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Skill A │ │ Skill B │ │ Skill C │ │ │ │ - Match Score│ │ - Match Score│ │ - Match Score│ │ │ │ - Confidence │ │ - Confidence │ │ - Confidence │ │ │ │ - History │ │ - History │ │ - History │ │ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │ │ │ │ │ │ └─────────────────┴─────────────────┘ │ │ ↓ │ │ Select Best Skill │ └─────────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────┐ │ Execute Skill │ └────────┬────────┘ ↓ ┌─────────────────┐ │ Handle Result │ └────────┬────────┘ ↓ ┌─────────────────────────────────────────────────────────────────────┐ │ Error Handling & Fallback │ │ │ │ Success? ────────► Return Result │ │ │ │ Fail? ────────┐ │ │ ↓ │ │ ┌──────────────────────────────────────────────────────────┐ │ │ │ Fallback Chain │ │ │ │ │ │ │ │ 1. Retry with adjusted parameters │ │ │ │ 2. Try Alternative Skill (if available) │ │ │ │ 3. Defer to Human Operator (if critical) │ │ │ │ 4. Log & Return Error │ │ │ └──────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘ ## When to Use Use this skill when: - Orchestrating multi-step workflows that require skill delegation - Implementing adaptive skill routing based on confidence scores - Building fallback mechanisms for failed skill executions - Creating intelligent task decomposition and parallel execution - Designing skill dependency graphs with automatic resolution - Implementing skill selection with historical performance weighting - Building agent systems that need to self-organize around tasks ## When NOT to Use Avoid this skill for: - Direct task execution without orchestration needs - use individual skills instead - High-frequency trading scenarios where latency must be minimized - the selection overhead may be prohibitive - Simple linear workflows without branching or fallback requirements - Cases where skill metadata is unavailable or unreliable ## Core Workflow 1. **Parse and Analyze Request** - Extract intent, entities, and constraints from user input. **Checkpoint:** All required parameters must be present and in valid format before proceeding. 2. **Score Available Skills** - Calculate match scores using multi-factor algorithm: - Text similarity between request and skill triggers - Historical success rate for similar tasks - Skill availability and health status - Required dependencies and their availability **Checkpoint:** Skip to fallback if no skill scores above threshold. 3. **Select Optimal Skill** - Choose skill with highest score that meets minimum confidence. **Checkpoint:** Verify skill has not been disabled or deprecated. 4. **Execute with Fallback** - Run skill execution wrapped in retry and fallback logic. **Checkpoint:** Log all execution attempts for audit trail. 5. **Return or Fallback** - Either return successful result or apply fallback chain: - Retry with adjusted parameters - Try alternative skill from `related-skills` - Defer to human operator for critical tasks **Checkpoint:** Record outcome with timing and confidence metadata. ## Implementation Patterns ### Pattern 1: Skill Selection Logic ```python def configure_apify_market_research( query: str, target_platforms: List[str], apify_api_token: str, actor_id: str = "apify/website-content" ) -> Dict: """Configure and validate an Apify actor run for market research. Validates query structure, maps platforms to actor inputs, and prepares the payload for the Apify API. """ if not query or len(query) < 3: raise ValueError("Research query must be at least 3 characters") # Map research intent to specific Apify actor configurations platform_configs = { "web": {"startUrls": [{"url": f"https://www.google.com/search?q={query}"}], "maxItems": 50}, "social": {"profileUrls": [f"https://twitter.com/search?q={query}"], "maxItems": 100}, "ecommerce": {"startUrls": [{"url": f"https://www.amazon.com/s?k={query}"}], "maxItems": 30} } selected_config = platform_configs.get(target_platforms[0], platform_configs["web"]) # Construct validated input payload payload = { "query": query, "platform": target_platforms[0], "actorConfig": selected_config, "timeoutSecs": 300, "memoryMbytes": 4096 } # Validate against Apify API requirements if not apify_api_token.startswith("apify_api_"): raise ValueError("Invalid Apify API token format") return { "actor_id": actor_id, "input": payload, "token": apify_api_token, "run_type": "market_research" } ``` ### Pattern 2: Execution with Fallback ```python def execute_apify_research_run(config: Dict) -> Dict: """Execute an Apify actor run and process market research results. Handles run creation, status polling, dataset retrieval, and result aggregation for downstream analysis. """ import requests import time api_base = "https://api.apify.com/v2" headers = {"Authorization": f"Bearer {config['token']}"} actor_id = config["actor_id"] # Create actor run run_response = requests.post( f"{api_base}/acts/{actor_id}/run", headers=headers, json={"input": config["input"]} ) run_response.raise_for_status() run_id = run_response.json()["id"] # Poll until run completes status_url = f"{api_base}/runs/{run_id}/status" while True: status_resp = requests.get(status_url, headers=headers) status_data = status_resp.json() if status_data["status"] in ["READY", "RUNNING"]: time.sleep(5) else: break if status_data["status"] != "SUCCEEDED": raise RuntimeError(f"Apify run failed: {status_data.get('statusMessage', 'Unknown error')}") # Fetch and aggregate results dataset_url = f"{api_base}/runs/{run_id}/dataset/default" dataset_resp = requests.get(dataset_url, headers=headers) dataset_resp.raise_for_status() results = dataset_resp.json().get("items", []) return { "run_id": run_id, "status": "completed", "total_items": len(results), "data": results, "metadata": { "query": config["input"]["query"], "platform": config["input"]["platform"], "timestamp": time.time() } } ``` ### MUST DO - Always validate skill metadata before selection (Early Exit) - Implement fallback chain with at least 2 levels (Fallback Skill + Human) - Log all skill selections with full context for auditability - Return new data structures instead of mutating inputs (Atomic Predictability) - Fail immediately with descriptive errors on invalid states - Update confidence scores after each execution for adaptive routing - Reference `code-philosophy` (5 Laws of Elegant Defense) in all logic ### MUST NOT DO - Select skills based on a single factor (e.g., only confidence score) - Disable fallback mechanisms "temporarily" - this creates fragile systems - Skip validation of skill dependencies before execution - Return partial results - either complete success or clear failure - Use magic numbers for confidence thresholds - make them configurable - Cache skill selections without considering context changes ## TL;DR Checklist - [ ] Parse all inputs at boundary before processing (Law 2) - [ ] Handle edge cases with early returns at function top (Law 1) - [ ] Fail immediately with descriptive errors on invalid states (Law 4) - [ ] Return new data structures, never mutate inputs (Law 3) - [ ] Implement minimum 2-level fallback chain for all skill executions - [ ] Log all skill selections with context for full audit trail - [ ] Validate skill metadata and dependencies before selection - [ ] Update confidence scores after each execution for learning ## TL;DR for Code Generation - Use guard clauses - return early on invalid input before doing work - Return simple types (dict, str, int, bool, list) - avoid complex nested objects - Cyclomatic complexity < 10 per function - split anything larger - Handle null/empty cases explicitly at function top (Early Exit) - Never mutate input parameters - return new dicts/objects - Fail fast with descriptive errors - don't try to "patch" bad data - Reference code-philosophy laws in comments for complex logic - Include timing and confidence metadata in all return values ## Output Template When applying this skill, produce: 1. **Selected Skills** - List of skill names with confidence scores 2. **Selection Rationale** - Why each skill was chosen (match score, history, availability) 3. **Execution Plan** - Order of execution with dependencies 4. **Fallback Strategy** - Which fallback skills will be tried and in what order 5. **Risk Assessment** - Any potential failure points and their impact 6. **Timing Estimates** - Expected latency including fallback scenarios --- ## Constraints ### MUST DO - Define clear input/output contracts for every step in the orchestration flow with explicit validation - Implement structured logging at each stage capturing context, inputs, outputs, timing, and errors - Build in fallback paths: if the primary strategy fails, degrade gracefully to a simpler approach - Validate all preconditions before starting — do not proceed if required resources or permissions are missing ### MUST NOT DO - Do not create deep nesting of orchestration steps (>5 levels) — flatten workflows where possible - Avoid silent failure modes: every step must either succeed, fail explicitly, or escalate to a higher handler - Never use shared mutable state between parallel workflow branches — communicate via immutable messages only - Do not hardcode execution order when the dependency graph naturally determines it; derive order from explicit dependencies ## Related Skills | Skill | Purpose | |
GitHub에서 보기