Skip to content

fsbtactic-code/marketing-brain-skill / skills/marketing-brain

marketing-brain

Flagged

Create, improve, research, or audit marketing strategy and execution using a bundled marketing library, verified live primary sources for volatile facts, and clearly labeled agent judgment. Use for full marketing systems, audits, landing pages and CRO, competitor intelligence, brand voice, audience and JTBD research, email sequences, SMM and social content systems, paid ads, headlines, copywriting, positioning, offers, launches, GTM, growth, funnels, retention, pricing, SEO, analytics, attribution, experiments, and consumer or buyer psychology. Trigger for English and Russian requests, including requests for ready-to-use assets.

FileKindSize
SKILL.mdskill md10.6 KB
agents/openai.yamlconfig325 B
assets/BUILD-MANIFEST.jsonconfig1.2 KB
assets/cards.jsonlother21.1 KB
assets/edges.jsonlother33.0 KB
assets/knowledge.sqlitebinary136.0 KB
assets/legacy-library.mbpack.parts/manifest.jsonconfig857 B
assets/legacy-library.mbpack.parts/part-0000.binbinary48.0 MB
assets/legacy-library.mbpack.parts/part-0001.binbinary48.0 MB
assets/legacy-library.mbpack.parts/part-0002.binbinary7.7 MB
assets/research-catalog.jsonlother280.4 KB
assets/source-channels.jsonlother52.1 KB
assets/sources.jsonlother10.2 KB
assets/templates/content-calendar.mdmarkdown1.3 KB
assets/templates/evidence-ledger.mdmarkdown1.3 KB
assets/templates/experiment-backlog.mdmarkdown1.2 KB
assets/templates/issue-registry.mdmarkdown1.2 KB
assets/templates/marketing-brief.mdmarkdown1.6 KB
assets/templates/marketing-system-manifest.jsonconfig1.1 KB
assets/wiki/cards/card_ad_effects_heterogeneous_by_firm.mdmarkdown1.3 KB
assets/wiki/cards/card_ad_roi_measurement_noise.mdmarkdown1.4 KB
assets/wiki/cards/card_choice_overload_context_dependent.mdmarkdown1.4 KB
assets/wiki/cards/card_cost_transparency_context.mdmarkdown1.2 KB
assets/wiki/cards/card_ftc_material_connection_disclosure.mdmarkdown1.4 KB
assets/wiki/cards/card_google_ads_experiment_hygiene.mdmarkdown1.3 KB
assets/wiki/cards/card_google_no_word_count_freshness_trick.mdmarkdown1.2 KB
assets/wiki/cards/card_google_people_first.mdmarkdown1.2 KB
assets/wiki/cards/card_google_who_how_why.mdmarkdown1.1 KB
assets/wiki/cards/card_incrementality_control_group.mdmarkdown1.2 KB
assets/wiki/cards/card_incrementality_precision_stratification.mdmarkdown1.3 KB
assets/wiki/cards/card_short_video_ad_spillover.mdmarkdown1.3 KB
assets/wiki/cards/card_telegram_ad_format.mdmarkdown1.0 KB
assets/wiki/cards/card_telegram_destination_quality.mdmarkdown1.1 KB
assets/wiki/cards/card_telegram_no_unsupported_absolutes.mdmarkdown1.0 KB
assets/wiki/cards/card_viral_content_arousal.mdmarkdown1.3 KB
assets/wiki/cards/card_youtube_audience_signals.mdmarkdown1.2 KB
assets/wiki/cards/card_youtube_publish_time.mdmarkdown1.4 KB
assets/wiki/cards/card_youtube_quality_over_frequency.mdmarkdown1.3 KB
assets/wiki/cards/card_youtube_search_ranking.mdmarkdown1.1 KB
assets/wiki/cards/card_youtube_tags_low_priority.mdmarkdown1019 B
assets/wiki/domains/consumer-behavior.mdmarkdown2.2 KB
assets/wiki/domains/content-editorial.mdmarkdown5.1 KB
assets/wiki/domains/creator-community.mdmarkdown1009 B
assets/wiki/domains/cro-funnels.mdmarkdown2.3 KB
assets/wiki/domains/law-policy-ethics.mdmarkdown2.8 KB
assets/wiki/domains/measurement-analytics.mdmarkdown4.5 KB
assets/wiki/domains/offer-messaging-copy.mdmarkdown2.7 KB
assets/wiki/domains/organic-smm.mdmarkdown4.9 KB
assets/wiki/domains/paid-acquisition.mdmarkdown6.2 KB
assets/wiki/domains/pricing-promotions.mdmarkdown850 B
assets/wiki/domains/seo-geo-ai-search.mdmarkdown2.8 KB
assets/wiki/domains/strategy-research.mdmarkdown932 B
assets/wiki/index.mdmarkdown935 B
assets/wiki/open-questions.mdmarkdown159 B
assets/wiki/pages.jsonlother18.3 KB
references/research-catalog-policy.mdmarkdown1.3 KB
references/retrieval-policy.mdmarkdown1.0 KB
references/task-playbooks.mdmarkdown5.1 KB
references/taxonomy.mdmarkdown1005 B
references/third-party-notices.mdmarkdown1.6 KB
references/workflow-audience.mdmarkdown8.4 KB
references/workflow-audit.mdmarkdown7.0 KB
references/workflow-brand-voice.mdmarkdown8.0 KB
references/workflow-competitors.mdmarkdown7.2 KB
references/workflow-email.mdmarkdown8.8 KB
references/workflow-full-system.mdmarkdown9.2 KB
references/workflow-headlines.mdmarkdown8.4 KB
references/workflow-landing-cro.mdmarkdown6.9 KB
references/workflow-paid-ads.mdmarkdown10.1 KB
references/workflow-social.mdmarkdown9.2 KB
scripts/marketing_context_output.pyscript7.3 KB
scripts/marketing_context_query.pyscript8.6 KB
scripts/materialize_legacy_pack.pyscript12.1 KB
scripts/mbpack_codec.pyscript4.1 KB
scripts/mbpack_output.pyscript5.2 KB
scripts/retrieve_marketing_context.pyscript13.1 KB
scripts/search_knowledge.pyscript7.2 KB
scripts/search_legacy_pack.pyscript131 B
scripts/search_private_pack.pyscript11.0 KB
scripts/search_research_catalog.pyscript6.2 KB
scripts/verify_public_install.pyscript7.1 KB

scripts/marketing_context_query.py

View on GitHub
from __future__ import annotations

import re
from typing import Any


DOMAIN_RESEARCH_ALIASES = {
    "strategy-research": "strategy_market",
    "segmentation-positioning": "segmentation_positioning",
    "offer-messaging-copy": "offer_copy",
    "consumer-behavior": "consumer_behavior",
    "pricing-promotions": "pricing_promo",
    "brand-creative": "brand_creative",
    "content-editorial": "content_editorial",
    "organic-smm": "organic_smm",
    "creator-community": "creator_community",
    "paid-acquisition": "paid_acquisition",
    "lifecycle-crm": "lifecycle_crm",
    "cro-funnels": "cro_funnels",
    "seo-geo-ai-search": "seo_geo",
    "measurement-analytics": "measurement_attribution",
    "b2b-saas-gtm": "b2b_saas",
    "law-policy-ethics": "policy_ethics",
}
DOMAIN_LOOKUP = {
    alias: canonical
    for canonical, research_alias in DOMAIN_RESEARCH_ALIASES.items()
    for alias in {
        canonical,
        canonical.replace("-", "_"),
        research_alias,
        research_alias.replace("_", "-"),
    }
}
RU_MARKETING_LEXICON = (
    ("маркетинг", ("marketing",)),
    ("смм", ("smm", "social", "media")),
    ("соцсет", ("social", "media")),
    ("контент", ("content", "editorial")),
    ("телеграм", ("telegram", "channel")),
    ("видео", ("video", "creator")),
    ("рилс", ("reels", "short", "video")),
    ("ютуб", ("youtube", "video")),
    ("продвиж", ("growth", "promotion", "acquisition")),
    ("продвиг", ("growth", "promotion", "acquisition")),
    ("реклам", ("advertising", "ads", "paid")),
    ("таргет", ("targeting", "paid", "ads")),
    ("аудитор", ("audience", "segmentation")),
    ("позиционир", ("positioning",)),
    ("сегмент", ("segmentation",)),
    ("оффер", ("offer", "messaging")),
    ("предложен", ("offer", "value", "proposition")),
    ("копирайт", ("copywriting", "copy")),
    ("лендинг", ("landing", "page")),
    ("воронк", ("funnel", "conversion")),
    ("конверси", ("conversion", "cro")),
    ("удержан", ("retention", "lifecycle")),
    ("рассыл", ("email", "crm", "lifecycle")),
    ("покуп", ("purchase", "buyer")),
    ("поведен", ("behavior", "decision")),
    ("психолог", ("psychology", "behavior")),
    ("аналитик", ("analytics", "measurement")),
    ("атрибуц", ("attribution", "measurement")),
    ("эксперимент", ("experiment", "testing")),
    ("цен", ("pricing",)),
    ("скидк", ("promotion", "pricing")),
    ("бренд", ("brand", "creative")),
    ("креатив", ("creative", "advertising")),
    ("запуск", ("launch", "gtm")),
    ("стратег", ("strategy",)),
    ("исследован", ("research",)),
    ("конкурент", ("competitor", "research")),
    ("продаж", ("sales", "revenue")),
    ("саас", ("saas", "b2b")),
    ("б2б", ("b2b", "saas", "gtm")),
    ("сео", ("seo", "search")),
)
QUERY_TOKEN_PATTERN = re.compile(r"[^\W_]+", re.UNICODE)
QUERY_STOP_TERMS = {
    "about",
    "and",
    "for",
    "from",
    "how",
    "the",
    "with",
    "как",
    "для",
    "или",
    "это",
    "через",
    "сделать",
    "сделай",
    "нужно",
}
PLATFORM_ANCHOR_TERMS = {
    "facebook",
    "instagram",
    "linkedin",
    "reddit",
    "telegram",
    "tiktok",
    "youtube",
}


def resolve_domain(domain: str | None) -> dict[str, Any]:
    if domain is None or not domain.strip():
        return {
            "requested": domain,
            "canonical": None,
            "knowledge": None,
            "research_catalog": None,
            "recognized": True,
        }
    requested = domain.strip().casefold()
    canonical = DOMAIN_LOOKUP.get(requested)
    if canonical is None:
        normalized = requested.replace("_", "-")
        return {
            "requested": domain,
            "canonical": normalized,
            "knowledge": normalized,
            "research_catalog": requested.replace("-", "_"),
            "recognized": False,
        }
    return {
        "requested": domain,
        "canonical": canonical,
        "knowledge": canonical,
        "research_catalog": DOMAIN_RESEARCH_ALIASES[canonical],
        "recognized": True,
    }


def query_tokens(value: str) -> list[str]:
    return [
        token.casefold()
        for token in QUERY_TOKEN_PATTERN.findall(value)
        if len(token) > 1 and token.casefold() not in QUERY_STOP_TERMS
    ]


def contains_cyrillic(value: str) -> bool:
    return any("\u0400" <= character <= "\u04ff" for character in value)


def russian_query_expansion(query: str) -> dict[str, Any]:
    additions: list[str] = []
    seen = set(query_tokens(query))
    for token in query_tokens(query):
        for stem, english_terms in RU_MARKETING_LEXICON:
            if not token.startswith(stem):
                continue
            for term in english_terms:
                if term not in seen:
                    additions.append(term)
                    seen.add(term)
            break
    return {
        "contains_cyrillic": contains_cyrillic(query),
        "lexicon": "ru-en-marketing-v1",
        "added_terms": additions,
        "effective_query": " ".join([query, *additions]).strip(),
    }


def relevance_terms(query: str, additions: list[str]) -> list[str]:
    terms = query_tokens(query)
    if not additions:
        return terms
    latin_terms = [term for term in terms if not contains_cyrillic(term)]
    return list(dict.fromkeys([*latin_terms, *additions]))


def _term_matches(term: str, searchable_tokens: set[str]) -> bool:
    if term in searchable_tokens:
        return True
    if len(term) < 5:
        return False
    return any(
        token.startswith(term) or term.startswith(token)
        for token in searchable_tokens
        if len(token) >= 5
    )


def card_relevance(card: dict[str, Any], terms: list[str]) -> dict[str, Any]:
    searchable = " ".join(
        [
            str(card.get("claim", "")),
            str(card.get("application", "")),
            str(card.get("conditions", "")),
            str(card.get("conditions_json", "")),
            str(card.get("limitations", "")),
            str(card.get("limitations_json", "")),
            str(card.get("domains", "")),
            str(card.get("domains_json", "")),
            *[
                str(source.get("title", ""))
                for source in card.get("source_details", [])
                if isinstance(source, dict)
            ],
        ]
    )
    searchable_tokens = set(query_tokens(searchable))
    unique_terms = list(dict.fromkeys(terms))
    matched = [term for term in unique_terms if _term_matches(term, searchable_tokens)]
    anchors = [term for term in unique_terms if term in PLATFORM_ANCHOR_TERMS]
    missing_anchors = [term for term in anchors if term not in matched]
    coverage = len(matched) / len(unique_terms) if unique_terms else 0.0
    if not unique_terms:
        label = "unscored"
    elif len(matched) == len(unique_terms) == 1:
        label = "strong"
    elif len(matched) >= 2 and coverage >= 0.34:
        label = "strong"
    elif matched:
        label = "partial"
    else:
        label = "none"
    if missing_anchors and label == "strong":
        label = "partial"
    return {
        "label": label,
        "matched_terms": matched,
        "missing_anchor_terms": missing_anchors,
        "considered_terms": unique_terms,
        "term_coverage": round(coverage, 3),
    }


def summarize_verified_coverage(cards: list[dict[str, Any]]) -> dict[str, Any]:
    relevances = [card["retrieval"]["relevance"] for card in cards]
    strong_count = sum(item["label"] == "strong" for item in relevances)
    partial_count = sum(item["label"] == "partial" for item in relevances)
    best_coverage = max(
        (float(item["term_coverage"]) for item in relevances),
        default=0.0,
    )
    status = "none" if not cards else "adequate" if strong_count else "weak"
    return {
        "status": status,
        "result_count": len(cards),
        "strong_result_count": strong_count,
        "partial_result_count": partial_count,
        "best_term_coverage": round(best_coverage, 3),
        "policy": "Adequate requires at least one strong lexical match. Weak results remain visible and labeled.",
    }


def coverage_rank(coverage: dict[str, Any]) -> tuple[int, int, float, int]:
    status_rank = {"none": 0, "weak": 1, "adequate": 2}
    return (
        status_rank[str(coverage["status"])],
        int(coverage["strong_result_count"]),
        float(coverage["best_term_coverage"]),
        int(coverage["result_count"]),
    )
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall