fsbtactic-code/marketing-brain-skill / skills/marketing-brain
marketing-brain
FlaggedCreate, 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.
scripts/mbpack_codec.py
View on GitHubfrom __future__ import annotations
import hashlib
import json
import re
import unicodedata
import zlib
from collections import Counter
from typing import Any
TOKEN_PATTERN = re.compile(r"[^\W_]{2,}", re.UNICODE)
EMAIL_PATTERN = re.compile(
r"(?<![\w.+-])[\w.+-]+@[\w-]+(?:\.[\w-]+)+(?![\w.-])",
re.UNICODE,
)
PHONE_PATTERN = re.compile(
r"(?<!\d)(?:\+?7|8)[\s().-]*(?:\d[\s().-]*){10}(?!\d)"
)
TELEGRAM_PATTERN = re.compile(r"(?<!\w)@[A-Za-z][A-Za-z0-9_]{4,31}(?!\w)")
IPV4_PATTERN = re.compile(r"(?<!\d)(?:\d{1,3}\.){3}\d{1,3}(?!\d)")
PAYMENT_CARD_PATTERN = re.compile(r"(?<!\d)(?:\d[ -]?){13,19}(?!\d)")
SECRET_PATTERN = re.compile(
r"(?i)\b(api[_ -]?key|access[_ -]?token|secret|password)\b"
r"\s*[:=]\s*[^\s,;]{8,}"
)
BEARER_PATTERN = re.compile(r"(?i)\bbearer\s+[a-z0-9._~+/=-]{12,}")
def passes_luhn_check(value: str) -> bool:
digits = [int(character) for character in value if character.isdigit()]
if not 13 <= len(digits) <= 19 or len(set(digits)) == 1:
return False
checksum = 0
parity = len(digits) % 2
for index, digit in enumerate(digits):
if index % 2 == parity:
digit *= 2
if digit > 9:
digit -= 9
checksum += digit
return checksum % 10 == 0
def normalized_tokens(text: str) -> list[str]:
normalized = unicodedata.normalize("NFKC", text).casefold()
return [match.group(0) for match in TOKEN_PATTERN.finditer(normalized)]
def token_counts(text: str) -> Counter[str]:
return Counter(normalized_tokens(text))
def term_hash(term: str, salt: bytes) -> bytes:
return hashlib.blake2b(
term.encode("utf-8"),
digest_size=16,
key=salt,
).digest()
def compress_text(text: str) -> bytes:
return zlib.compress(text.encode("utf-8"), level=9)
def decompress_text(blob: bytes) -> str:
return zlib.decompress(blob).decode("utf-8")
def compress_json(value: dict[str, Any]) -> bytes:
payload = json.dumps(
value,
ensure_ascii=False,
separators=(",", ":"),
sort_keys=True,
).encode("utf-8")
return zlib.compress(payload, level=9)
def decompress_json(blob: bytes) -> dict[str, Any]:
value = json.loads(zlib.decompress(blob).decode("utf-8"))
if not isinstance(value, dict):
raise ValueError("Compressed JSON value must be an object")
return value
def redact_sensitive_text(text: str) -> tuple[str, int]:
replacements = 0
def replace(pattern: re.Pattern[str], value: str, replacement: str) -> str:
nonlocal replacements
value, count = pattern.subn(replacement, value)
replacements += count
return value
def replace_payment_card(match: re.Match[str]) -> str:
nonlocal replacements
if not passes_luhn_check(match.group(0)):
return match.group(0)
replacements += 1
return "[REDACTED_PAYMENT_CARD]"
redacted = replace(EMAIL_PATTERN, text, "[REDACTED_EMAIL]")
redacted = PAYMENT_CARD_PATTERN.sub(replace_payment_card, redacted)
redacted = replace(PHONE_PATTERN, redacted, "[REDACTED_PHONE]")
redacted = replace(TELEGRAM_PATTERN, redacted, "[REDACTED_TELEGRAM]")
redacted = replace(IPV4_PATTERN, redacted, "[REDACTED_IPV4]")
redacted = replace(SECRET_PATTERN, redacted, "[REDACTED_SECRET]")
redacted = replace(BEARER_PATTERN, redacted, "[REDACTED_TOKEN]")
return redacted, replacements
def redact_sensitive_value(value: Any) -> tuple[Any, int]:
if isinstance(value, str):
return redact_sensitive_text(value)
if isinstance(value, dict):
redacted: dict[str, Any] = {}
replacements = 0
for key, nested in value.items():
redacted_value, count = redact_sensitive_value(nested)
redacted[key] = redacted_value
replacements += count
return redacted, replacements
if isinstance(value, list):
redacted_items: list[Any] = []
replacements = 0
for nested in value:
redacted_value, count = redact_sensitive_value(nested)
redacted_items.append(redacted_value)
replacements += count
return redacted_items, replacements
return value, 0
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 471k | Updated | Claude CodeCodex | Verified | Install |
| 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: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |