Skip to content

Harmix/open-stanley / open-stanley/skills/stanley

stanley

Verified

Your head of content. Use this whenever the user wants help with LinkedIn or X (Twitter) — writing or scheduling a post, finding things to comment on, turning a meeting, voice note, or Slack thread into a post, reviewing why a post did or didn't work, planning the week's content, or asking "what should I post". Also use it for anything that mentions Stanley, ghostwriting, personal brand, founder-led content, building in public, or growing followers, even if the user doesn't say "post". Start here; it routes to the other open-stanley skills and holds the operating rules they all share.

FileKindSize
SKILL.mdskill md14.2 KB
references/capabilities.mdmarkdown3.3 KB
references/platform-access.mdmarkdown4.0 KB
references/recommended-mcps.mdmarkdown5.5 KB
references/recommended.mcp.jsonconfig2.0 KB
references/research-linkedin-2026.mdmarkdown6.7 KB
references/scheduling.mdmarkdown8.6 KB
references/vault-backends.mdmarkdown6.8 KB
references/verify-live.mdmarkdown2.2 KB
references/why-these-rules.mdmarkdown2.1 KB
scripts/stanley-auditexecutablescript24.6 KB
scripts/stanley-briefexecutablescript6.4 KB
scripts/stanley-chartexecutablescript14.5 KB
scripts/stanley-previewexecutablescript5.8 KB
scripts/stanley-statsexecutablescript14.9 KB
scripts/stanley-traceother6.3 KB
scripts/stanley-vaultexecutablescript35.1 KB

scripts/stanley-stats

View on GitHub
#!/usr/bin/env python3
"""stanley-stats: what is working, computed from the ledger, not remembered.

Reads ledger/posts.jsonl (each line may carry `lane`, `shape` (opener/body/ending
tags), `platform`, `text`, `metrics` {bucket: {impressions, reactions, comments, reposts, saves}})
and ledger/comments.jsonl. Prints medians and lifts by lane, shape, and hook
feature, plus the status of every experiment declared in strategy.md.

Usage:
  stanley-stats [--vault DIR] [--platform linkedin|x] [--metric reactions|comments|impressions|engagement] [--days 90] [--json]
  stanley-stats --predict drafts/<slug>.md [--lane L] [--has-image]   reach band from your own ledger for a draft

An experiment in strategy.md is a line like:
  - experiment: number-in-hook | variants: with, without | metric: engagement | min_n: 4
  - experiment: ending | variants: open-question, flat | metric: comments | min_n: 4 | classify: ends-with-question
Posts opt into a variant with `experiment: {"number-in-hook": "with"}` in their ledger entry.
If the experiment names an observable property of the text -- either the experiment name is
itself a hook feature, or `classify:` names one -- every untagged post is classified from its
text instead (true -> first variant, false -> second). Arms then fill from history rather than
waiting on a tag nobody remembers to write; posts published outside the write/publish path
still count. Tags win over classification where both exist.
The script reports per-variant medians and whether min_n is met; it does not claim significance
below n=8 per arm, and says so.
"""
import argparse, json, os, re, statistics as st, sys, datetime as dt
from pathlib import Path

def read_jsonl(p):
    if not p.exists(): return []
    out = []
    for line in p.read_text(encoding="utf-8").splitlines():
        try: out.append(json.loads(line))
        except Exception: pass
    return out

def metric_of(post, metric, bucket_pref=("7d", "24h", "1h")):
    m = post.get("metrics") or {}
    for b in bucket_pref:
        if b in m and isinstance(m[b], dict):
            d = m[b]
            if metric == "engagement":
                return (d.get("reactions", 0) or 0) + 2 * (d.get("comments", 0) or 0) + 3 * (d.get("reposts", 0) or 0) + (d.get("saves", 0) or 0)
            return d.get(metric)
    return None

SHAPE_AXES = ("opener", "body", "ending")

def shape_keys(post):
    """Categorical shape keys only. Free-text fields (receipt, note) become presence flags so they never split into n=1 buckets."""
    sh = post.get("shape") or {}
    keys = [f"{k}:{sh[k]}" for k in SHAPE_AXES if sh.get(k)]
    if "receipt" in sh: keys.append("receipt:" + ("yes" if sh.get("receipt") else "no"))
    if "hashtags" in sh: keys.append("hashtags:" + ("0" if not sh.get("hashtags") else "1+"))
    return keys

def hook_features(text):
    hook = (text or "").strip().split("\n")[0]
    return {
        "number-in-hook": bool(re.search(r"\d", hook)),
        "question-hook": hook.strip().endswith("?"),
        "first-person-hook": bool(re.search(r"\b(I|we|my|our)\b", hook)),
        "short-hook(<=80c)": len(hook) <= 80,
        "ends-with-question": (text or "").strip().endswith("?"),
        "has-em-dash": "—" in (text or ""),
        "story-length(900-2000c)": 900 <= len(text or "") <= 2000,
    }

def draft_features(text, lane=None, has_image=False):
    """The observable features a draft shares with ledger rows: lane, hook features, image, length band."""
    f = {k for k, on in hook_features(text).items() if on}
    if lane: f.add("lane:" + lane)
    if has_image: f.add("image:yes")
    first = (text or "").strip().split("\n")[0]
    if re.search(r"\b[A-Z][a-zA-Z]+(?: [A-Z][a-zA-Z]+)*\b", first[1:] if first[:1].isupper() else first): f.add("named-entity-early")
    return f

def quantiles(xs):
    xs = sorted(x for x in xs if x is not None)
    if not xs: return None
    def q(p):
        k = (len(xs) - 1) * p; lo = int(k); hi = min(lo + 1, len(xs) - 1)
        return xs[lo] + (xs[hi] - xs[lo]) * (k - lo)
    return {"p25": round(q(0.25)), "median": round(q(0.5)), "p75": round(q(0.75)), "n": len(xs)}

def predict(draft_path, posts, platform, lane, has_image, as_json):
    """Reach band for a draft, from the user's own ledger: take the posts that share the most features with it
    (lane, image, hook features, a name early) and report p25/median/p75 of impressions and engagement.
    This is a band, not a number: it says 'posts like this one did X to Y for you', which is all the ledger can know."""
    import json as _json
    text = draft_path.read_text(encoding="utf-8")
    if text.startswith("---"):   # strip front matter
        parts = text.split("---", 2)
        if len(parts) == 3: text = parts[2]
    meta_path = draft_path.with_suffix(".meta.json")
    meta = _json.loads(meta_path.read_text()) if meta_path.exists() else {}
    lane = lane or meta.get("lane")
    has_image = has_image or bool(meta.get("image"))
    want = draft_features(text, lane, has_image)
    pool = [p for p in posts if p.get("metrics") and (not platform or p.get("platform") == platform)]
    if len(pool) < 3:
        return "predict: fewer than 3 posts with metrics in the window; no band yet (post more, the ledger learns)"
    scored = []
    for p in pool:
        have = draft_features(p.get("text", ""), p.get("lane"), bool(p.get("image")))
        scored.append((len(want & have), p))
    best = max(s for s, _ in scored)
    similar = [p for s, p in scored if s >= max(1, best - 1)]
    if len(similar) < 3: similar = [p for s, p in sorted(scored, key=lambda t: -t[0])[:3]]
    imp = quantiles([metric_of(p, "impressions") for p in similar]); eng = quantiles([metric_of(p, "engagement") for p in similar])
    base_imp = quantiles([metric_of(p, "impressions") for p in pool]); base_eng = quantiles([metric_of(p, "engagement") for p in pool])
    out = {"features": sorted(want), "similar_posts": len(similar), "of": len(pool), "impressions": imp, "engagement": eng, "baseline_impressions": base_imp, "baseline_engagement": base_eng,
           "examples": [{"hook": (p.get("hook") or p.get("text", ""))[:80], "impressions": metric_of(p, "impressions")} for p in sorted(similar, key=lambda p: -(metric_of(p, "impressions") or 0))[:3]]}
    if as_json: return _json.dumps(out, indent=1)
    lines = [f"predict: {len(similar)} of your {len(pool)} posts share these features: {', '.join(sorted(want)) or 'none'}"]
    if imp: lines.append(f"  impressions  p25 {imp['p25']:,}  median {imp['median']:,}  p75 {imp['p75']:,}   (all posts: median {base_imp['median']:,})")
    if eng: lines.append(f"  engagement   p25 {eng['p25']}  median {eng['median']}  p75 {eng['p75']}   (all posts: median {base_eng['median']})")
    lines.append("  a band from your own ledger, not a forecast: one post in the set can be 30x the median (n=%d)" % len(similar))
    for e in out["examples"]: lines.append(f"  e.g. {e['impressions'] or 0:>7,}  {e['hook']}")
    return "\n".join(lines)

def median(xs):
    xs = [x for x in xs if x is not None]
    return (st.median(xs), len(xs)) if xs else (None, 0)

def lift_table(rows, key_fn, metric, base_median):
    groups = {}
    for p in rows:
        for k in key_fn(p):
            groups.setdefault(k, []).append(metric_of(p, metric))
    out = []
    for k, vals in groups.items():
        med, n = median(vals)
        if med is None: continue
        lift = (med / base_median) if base_median else None
        out.append({"key": k, "n": n, "median": med, "lift": round(lift, 2) if lift else None, "signal": n >= 3})
    return sorted(out, key=lambda r: -(r["lift"] or 0))

def parse_experiments(vault):
    p = vault / "strategy.md"
    if not p.exists(): return []
    exps = []
    for line in p.read_text(encoding="utf-8").splitlines():
        m = re.search(r"experiment:\s*([\w\-]+)\s*\|\s*variants:\s*([^|]+)\|\s*metric:\s*(\w+)(?:\s*\|\s*min_n:\s*(\d+))?(?:\s*\|\s*classify:\s*([\w\-()<=]+))?", line)
        if m:
            exps.append({"name": m.group(1), "variants": [v.strip() for v in m.group(2).split(",")],
                         "metric": m.group(3), "min_n": int(m.group(4) or 4), "classify": m.group(5)})
    return exps

def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--vault", default=os.environ.get("STANLEY_VAULT", "./stanley-vault"))
    ap.add_argument("--platform"); ap.add_argument("--metric", default="engagement"); ap.add_argument("--days", type=int, default=90)
    ap.add_argument("--json", action="store_true")
    ap.add_argument("--experiments", action="store_true", help="print only the experiment arms (what the Sunday tune reads)")
    ap.add_argument("--predict", metavar="DRAFT", help="a draft .md: print the reach band (p25-median-p75 impressions and engagement) of the user's own past posts that share the most features with it")
    ap.add_argument("--lane", help="with --predict: the draft's lane (else read from <draft>.meta.json)")
    ap.add_argument("--has-image", action="store_true", help="with --predict: the draft will carry an image")
    a = ap.parse_args()
    v = Path(a.vault).expanduser()
    if not (v / "ledger").exists() and (Path.cwd() / "my-human.md").exists():
        v = Path.cwd()   # run from inside the vault, same rule as stanley-vault
    if not (v / "ledger").exists():
        sys.exit(f"no vault at {v}; pass --vault or run from inside the vault")
    posts = read_jsonl(v / "ledger/posts.jsonl")
    cutoff = (dt.date.today() - dt.timedelta(days=a.days)).isoformat()
    posts = [p for p in posts if p.get("date", "9999") >= cutoff and (not a.platform or p.get("platform") == a.platform) and p.get("kind", "post") != "repost"]
    with_metrics = [p for p in posts if metric_of(p, a.metric) is not None]
    if a.predict:
        print(predict(Path(a.predict), posts, a.platform, a.lane, a.has_image, a.json)); return
    base, n = median([metric_of(p, a.metric) for p in with_metrics])
    report = {"posts": len(posts), "posts_with_metrics": n, "metric": a.metric, "median": base, "by_lane": [], "by_shape": [], "by_hook_feature": [], "experiments": []}
    if n:
        report["by_lane"] = lift_table(with_metrics, lambda p: [p.get("lane")] if p.get("lane") else [], a.metric, base)
        report["by_shape"] = lift_table(with_metrics, shape_keys, a.metric, base)
        report["by_hook_feature"] = lift_table(with_metrics, lambda p: [k for k, on in hook_features(p.get("text", "")).items() if on], a.metric, base)
        report["top"] = sorted(({"url": p.get("url"), "hook": p.get("hook"), "value": metric_of(p, a.metric)} for p in with_metrics), key=lambda r: -r["value"])[:3]
        # Reach vs pull: the post people saw most is often not the post people reacted to most.
        by_imp = [p for p in posts if metric_of(p, "impressions") is not None]
        if by_imp:
            top_imp = max(by_imp, key=lambda p: metric_of(p, "impressions"))
            report["top_by_reach"] = {"url": top_imp.get("url"), "hook": top_imp.get("hook"), "impressions": metric_of(top_imp, "impressions"), "engagement": metric_of(top_imp, "engagement")}
        report["bottom"] = sorted(({"url": p.get("url"), "hook": p.get("hook"), "value": metric_of(p, a.metric)} for p in with_metrics), key=lambda r: r["value"])[:3]
    for e in parse_experiments(v):
        classified = 0
        arms = {}
        for p in with_metrics:
            var = (p.get("experiment") or {}).get(e["name"])
            if not var:
                # observable property? classify from the text instead of waiting on a tag.
                feats = hook_features(p.get("text", ""))
                key = e.get("classify") or e["name"]
                if key in feats and len(e["variants"]) == 2:
                    var = e["variants"][0] if feats[key] else e["variants"][1]
                    classified += 1
            if var: arms.setdefault(var, []).append(metric_of(p, e["metric"]))
        arm_stats = {k: {"n": len(xs), "median": median(xs)[0]} for k, xs in arms.items()}
        ready = all(arm_stats.get(vname, {}).get("n", 0) >= e["min_n"] for vname in e["variants"])
        verdict = "not enough posts yet" if not ready else ("directional only (n<8 per arm)" if any(s["n"] < 8 for s in arm_stats.values()) else "compare medians")
        report["experiments"].append({**e, "arms": arm_stats, "status": verdict, "classified": classified})
    if a.json:
        print(json.dumps(report, indent=1)); return
    if a.experiments:
        if not report["experiments"]: print("no experiments in strategy.md (## Experiments: `- name: a | b; metric: engagement; min_n: 4`)")
        for e in report["experiments"]:
            print(f"experiment {e['name']} ({e['metric']}): {e['status']}" + (f"  [{e['classified']} arm(s) read from the text, not tagged]" if e.get("classified") else ""))
            for k, s in e["arms"].items():
                starving = "  <- starving" if s["n"] < e["min_n"] and max(x["n"] for x in e["arms"].values()) >= e["min_n"] else ""
                print(f"  {k:12} n={s['n']} median={s['median']}{starving}")
        return
    print(f"{report['posts']} posts in {a.days}d, {n} with metrics. Median {a.metric}: {base}")
    for title, rows in (("by lane", report["by_lane"]), ("by shape", report["by_shape"]), ("by hook feature", report["by_hook_feature"])):
        if rows:
            print(f"\n{title}:")
            for r in rows: print(f"  {r['key']:32} n={r['n']:<3} median={r['median']:<8} lift={r['lift']}" + ("   (n<3: not a signal)" if r['n'] < 3 else ""))
    if report.get("top_by_reach"):
        r = report["top_by_reach"]
        print(f"\ntop by reach: {r['impressions']} impressions / {r['engagement']} engagement  {r['hook'][:70]}")
        if report.get("top") and report["top"][0]["url"] != r["url"] and a.metric != "impressions":
            print("  note: the most-seen post is not the most-reacted-to post. Reach and pull are different games; read both before naming a 'best post'.")
    if report.get("top"):
        print("\ntop:"); [print(f"  {r['value']:<6} {r['hook'][:70]}") for r in report["top"]]
        print("bottom:"); [print(f"  {r['value']:<6} {r['hook'][:70]}") for r in report["bottom"]]
    for e in report["experiments"]:
        print(f"\nexperiment {e['name']} ({e['metric']}): {e['status']}" + (f"  [{e['classified']} arm(s) read from the text, not tagged]" if e.get("classified") else ""))
        for k, s in e["arms"].items(): print(f"  {k:12} n={s['n']} median={s['median']}")
    rt = [p.get("metrics", {}).get("7d", {}).get("reaction_types") or p.get("metrics", {}).get("24h", {}).get("reaction_types") for p in with_metrics]
    rt = [x for x in rt if x]
    if rt:
        tot = sum(sum(x.values()) for x in rt); ins = sum(x.get("insight", 0) for x in rt); like = sum(x.get("like", 0) for x in rt)
        if tot:
            print(f"\nreactions by type over {len(rt)} post(s): insight share {100*ins/tot:.1f}%  like share {100*like/tot:.1f}%  (226K-post study: insight is the best predictor of reposts; a like share above ~85% means people scrolled past)")
    if n and n < 8:
        print("\nnote: fewer than 8 posts with metrics; treat every lift above as a hint, not a finding.")

if __name__ == "__main__":
    main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall