Skip to content

markleetw/reverse-due-diligence-skill

反向盡職調查(reverse due diligence)——求職者視角的公司調查。在接受 offer 或投入面試流程前,用公開資料把公司的財務體質、股價與股權、營收引擎、組織文化、低潮期與復原路徑查清楚,產出一份可存檔的 HTML 報告與一份面試提問清單。這個 skill 的簡稱是 rdd,使用者打 /rdd 就是要跑這套流程。Use this whenever the user is evaluating a job opportunity and wants to research the company behind it — triggers include /rdd, rdd, 反向盡職調查, 反向盡調, 調查這家公司, 我在面試某公司想先了解, 這份工作值不值得接, 幫我查某公司的財報與風評, 這家公司值得去嗎, background check on an employer, should I take this job, research this company before I interview, vet this employer. Also use when they name a company plus a role and ask what they should know about it, even if they never say the words "due diligence" or "rdd".

scripts/package.py

View on GitHub
#!/usr/bin/env python3
"""Build and verify the deterministic RDD runtime ZIP.

All distribution jobs share this manifest and verification logic. The ZIP has
one top-level rdd/ directory; source, license and embedded version
travel together. Development-only files remain outside the package.
"""
from __future__ import annotations

import argparse
import hashlib
import os
import sys
import zipfile
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
PACKAGE_ROOT = "rdd"
FIXED_TIME = (1980, 1, 1, 0, 0, 0)
INCLUDE_FILES = [
    Path("SKILL.md"),
    Path("LICENSE"),
    Path("VERSION"),
    Path("references/analysis-playbook.md"),
    Path("references/global-sources.md"),
    Path("references/report-template.md"),
    Path("references/taiwan-sources.md"),
    Path("templates/report-shell.html"),
    Path("scripts/audit.py"),
]
EXECUTABLES = {Path("scripts/audit.py")}


def sha256(path: Path) -> str:
    digest = hashlib.sha256()
    with path.open("rb") as fh:
        for chunk in iter(lambda: fh.read(1024 * 1024), b""):
            digest.update(chunk)
    return digest.hexdigest()


def verify_package(path: Path, expected_version: str | None = None) -> None:
    """Inspect the *actual* archive: names, integrity, bytes and version."""
    expected = {f"{PACKAGE_ROOT}/{rel.as_posix()}" for rel in INCLUDE_FILES}
    with zipfile.ZipFile(path) as archive:
        names = archive.namelist()
        if len(names) != len(set(names)) or set(names) != expected:
            raise ValueError(
                f"package manifest mismatch: expected={sorted(expected)}; "
                f"actual={sorted(names)}"
            )
        corrupt = archive.testzip()
        if corrupt:
            raise ValueError(f"ZIP corruption detected at {corrupt}")
        for rel in INCLUDE_FILES:
            member = f"{PACKAGE_ROOT}/{rel.as_posix()}"
            if archive.read(member) != (ROOT / rel).read_bytes():
                raise ValueError(f"archive bytes differ from source: {member}")
            entry = archive.getinfo(member)
            if entry.date_time != FIXED_TIME:
                raise ValueError(f"non-reproducible archive timestamp: {member}")
        version = archive.read(f"{PACKAGE_ROOT}/VERSION").decode("utf-8").strip()
        if expected_version and version != expected_version:
            raise ValueError(
                f"ZIP VERSION {version!r} does not match {expected_version!r}"
            )
    print(f"Verified {path}: {len(expected)} exact files, VERSION {version}")
    print(f"SHA256 {sha256(path)}")


def build(output: Path) -> None:
    missing = [str(rel) for rel in INCLUDE_FILES if not (ROOT / rel).is_file()]
    if missing:
        raise SystemExit("Missing runtime files:\n- " + "\n- ".join(missing))
    output.parent.mkdir(parents=True, exist_ok=True)
    tmp = output.with_suffix(output.suffix + ".tmp")
    if tmp.exists():
        tmp.unlink()
    with zipfile.ZipFile(
        tmp, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9
    ) as archive:
        for rel in sorted(INCLUDE_FILES, key=lambda p: p.as_posix()):
            info = zipfile.ZipInfo(
                f"{PACKAGE_ROOT}/{rel.as_posix()}", date_time=FIXED_TIME
            )
            info.compress_type = zipfile.ZIP_DEFLATED
            info.create_system = 3
            mode = 0o755 if rel in EXECUTABLES else 0o644
            info.external_attr = (mode & 0xFFFF) << 16
            info.flag_bits |= 0x800
            archive.writestr(info, (ROOT / rel).read_bytes())
    os.replace(tmp, output)
    verify_package(output)


def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--output", type=Path,
        default=ROOT / "dist" / "reverse-due-diligence.zip",
        help="Build a deterministic ZIP at this path",
    )
    parser.add_argument(
        "--verify", type=Path,
        help="Verify an already built ZIP (no rewriting)",
    )
    parser.add_argument(
        "--expected-version", type=str,
        help="Require this VERSION inside the verified archive",
    )
    args = parser.parse_args()
    if args.verify:
        verify_package(args.verify, expected_version=args.expected_version)
    else:
        build(args.output)
        if args.expected_version:
            verify_package(args.output, expected_version=args.expected_version)
    return 0


if __name__ == "__main__":
    sys.exit(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