Skip to content

brycewang-stanford/Auto-Empirical-Research-Skills / skills/35-bahayonghang-academic-writing-skills/skills/paper-audit

paper-audit

Verified

Deep-review-first audit for Chinese and English academic papers across LaTeX, Typst, and PDF formats. Use whenever the user wants reviewer-style paper critique, pre-submission readiness checks, pass/fail gate decisions, structured revision roadmaps, or re-audits of revised manuscripts. Trigger even if the user only says "review my paper", "check if this is ready to submit", "audit this PDF", "simulate peer review", "find the biggest problems in this manuscript", or "re-check whether I fixed the review issues". Do not use for direct source editing or compilation-heavy repair; route those to the format-specific writing skills instead.

FileKindSize
SKILL.mdskill md14.3 KB
agents/claims_evidence_reviewer_agent.mdmarkdown354 B
agents/committee_editor_agent.mdmarkdown1.9 KB
agents/committee_literature_agent.mdmarkdown1.9 KB
agents/committee_logic_agent.mdmarkdown1.5 KB
agents/committee_methodology_agent.mdmarkdown1.8 KB
agents/committee_theory_agent.mdmarkdown1.9 KB
agents/critical_reviewer_agent.mdmarkdown8.4 KB
agents/domain_reviewer_agent.mdmarkdown7.1 KB
agents/editor_in_chief_agent.mdmarkdown5.2 KB
agents/evaluation_fairness_reviewer_agent.mdmarkdown371 B
agents/literature_reviewer_agent.mdmarkdown3.6 KB
agents/methodology_reviewer_agent.mdmarkdown7.2 KB
agents/notation_consistency_reviewer_agent.mdmarkdown398 B
agents/prior_art_reviewer_agent.mdmarkdown2.9 KB
agents/section_reviewer_agent.mdmarkdown365 B
agents/self_consistency_reviewer_agent.mdmarkdown420 B
agents/synthesis_agent.mdmarkdown951 B
evals/evals.jsonconfig12.0 KB
evals/fixtures/deep_review_fixture.texother699 B
evals/fixtures/gate_ieee_fixture.texother617 B
evals/fixtures/polish_fixture.texother396 B
evals/fixtures/previous_final_issues.jsonconfig1.1 KB
evals/fixtures/previous_review_report.mdmarkdown205 B
evals/fixtures/quick_audit_fixture.texother538 B
examples/gate_example.mdmarkdown3.5 KB
examples/review_example.mdmarkdown2.5 KB
examples/self_check_example.mdmarkdown2.9 KB
references/AUDIT_GUIDE.mdmarkdown3.4 KB
references/CHANGELOG.mdmarkdown530 B
references/CHECKLIST.mdmarkdown6.0 KB
references/CONSOLIDATION_RULES.mdmarkdown907 B
references/DEEP_REVIEW_CRITERIA.mdmarkdown2.8 KB
references/FORBIDDEN_TERMS.mdmarkdown6.4 KB
references/ISSUE_SCHEMA.mdmarkdown928 B
references/LITERATURE_GROUNDING_GUIDE.mdmarkdown3.3 KB
references/POLISH_GUIDE.mdmarkdown2.3 KB
references/QUALITATIVE_STANDARDS.mdmarkdown5.5 KB
references/QUICK_REFERENCE.mdmarkdown1.1 KB
references/REVIEW_CRITERIA.mdmarkdown2.7 KB
references/REVIEW_LANE_GUIDE.mdmarkdown828 B
references/SCHOLAR_EVAL_GUIDE.mdmarkdown6.4 KB
references/SCORING_SYSTEMS.mdmarkdown1000 B
references/SUBAGENT_TEMPLATES.mdmarkdown987 B
references/TROUBLESHOOTING.mdmarkdown1.4 KB
references/VENUE_RULES.mdmarkdown764 B
references/editorial_decision_standards.mdmarkdown6.7 KB
references/quality_rubrics.mdmarkdown10.8 KB
scripts/audit.pyscript78.4 KB
scripts/build_claim_map.pyscript3.3 KB
scripts/check_citations.pyscript5.6 KB
scripts/check_references.pyscript19.9 KB
scripts/consolidate_review_findings.pyscript5.2 KB
scripts/detect_language.pyscript1.9 KB
scripts/diff_review_issues.pyscript2.0 KB
scripts/literature_compare.pyscript11.4 KB
scripts/literature_search.pyscript22.0 KB
scripts/models/scoring_model.jsonconfig737 B
scripts/parsers.pyscript3.3 KB
scripts/pdf_parser.pyscript11.4 KB
scripts/prepare_review_workspace.pyscript6.8 KB
scripts/render_deep_review_report.pyscript3.5 KB
scripts/report_generator.pyscript36.2 KB
scripts/scholar_eval.pyscript13.7 KB
scripts/scoring_model.pyscript6.2 KB
scripts/verify_quotes.pyscript1.6 KB
scripts/visual_check.pyscript10.7 KB
templates/audit_report_template.mdmarkdown2.8 KB
templates/final_issues_template.jsonconfig498 B
templates/review_report_template.mdmarkdown678 B
templates/revision_roadmap_template.mdmarkdown3.1 KB

scripts/prepare_review_workspace.py

View on GitHub
"""Prepare a deep-review workspace from a paper source file."""

from __future__ import annotations

import argparse
import json
import re
import shutil
from datetime import datetime
from pathlib import Path

from build_claim_map import build_claim_map
from detect_language import detect_language
from parsers import extract_title, get_parser


def slugify(value: str) -> str:
    """Convert a filename or title into a filesystem-safe slug."""
    slug = re.sub(r"[^a-zA-Z0-9]+", "-", value).strip("-").lower()
    return slug or "paper"


def _section_lines(lines: list[str], start: int, end: int, zero_based: bool) -> str:
    if zero_based:
        return "\n".join(lines[start : end + 1]).strip()
    return "\n".join(lines[max(0, start - 1) : end]).strip()


def build_section_index(content: str, parser, fmt: str) -> list[dict]:
    """Turn parser section tuples into portable section metadata."""
    sections = parser.split_sections(content)
    lines = content.splitlines()
    zero_based = fmt == ".pdf"
    index: list[dict] = []

    for section_key, (start, end) in sections.items():
        body = _section_lines(lines, start, end, zero_based=zero_based)
        index.append(
            {
                "section_key": section_key,
                "title": section_key.replace("_", " ").title(),
                "start_line": start,
                "end_line": end,
                "line_base": 0 if zero_based else 1,
                "word_count": len(body.split()),
                "char_count": len(body),
                "file_name": f"{section_key}.md",
            }
        )

    return sorted(index, key=lambda item: item["start_line"])


def write_summary_stub(
    workspace: Path,
    title: str,
    claim_map: dict,
    section_index: list[dict],
) -> None:
    """Write a structured summary stub the reviewer can refine."""
    lines = [
        f"# Paper Summary: {title}",
        "",
        "## Research Question",
        "- TODO",
        "",
        "## Core Thesis",
        "- TODO",
        "",
        "## Headline Claims",
    ]
    if claim_map["headline_claims"]:
        lines.extend([f"- {claim}" for claim in claim_map["headline_claims"]])
    else:
        lines.append("- TODO")
    lines.extend(["", "## Section Map"])
    for section in section_index:
        lines.append(
            f"- {section['section_key']} ({section['start_line']}-{section['end_line']}): "
            f"{section['word_count']} words"
        )
    lines.extend(["", "## Closure Targets"])
    if claim_map["closure_targets"]:
        lines.extend([f"- {claim}" for claim in claim_map["closure_targets"]])
    else:
        lines.append("- TODO")
    (workspace / "paper_summary.md").write_text("\n".join(lines), encoding="utf-8")


def _copy_workspace_references(workspace: Path) -> None:
    """Copy a small reference set into the workspace for reviewer agents.

    Reviewer lane templates read `<review_dir>/references/...`, so keep the workspace
    self-contained even when the audit is run from other working directories.
    """
    skill_root = Path(__file__).resolve().parent.parent
    source_dir = skill_root / "references"
    dest_dir = workspace / "references"
    dest_dir.mkdir(parents=True, exist_ok=True)

    minimal_refs = (
        "DEEP_REVIEW_CRITERIA.md",
        "ISSUE_SCHEMA.md",
        "REVIEW_LANE_GUIDE.md",
        "CONSOLIDATION_RULES.md",
        "CHECKLIST.md",
        "QUALITATIVE_STANDARDS.md",
    )
    for name in minimal_refs:
        src = source_dir / name
        if not src.exists():
            continue
        shutil.copy2(src, dest_dir / name)


def prepare_workspace(input_path: str, output_dir: str = "./review_results") -> Path:
    """Create deep-review workspace files and return the workspace path."""
    source = Path(input_path).resolve()
    if not source.exists():
        raise FileNotFoundError(f"Input file not found: {input_path}")

    fmt = source.suffix.lower()
    parser = get_parser(str(source))
    if fmt == ".pdf":
        content = parser.extract_text_from_file(str(source))
    else:
        content = source.read_text(encoding="utf-8")

    visible_text = parser.clean_text(content, keep_structure=True)
    language = detect_language(parser.clean_text(content))
    title = extract_title(content) if fmt in {".tex", ".typ"} else source.stem
    slug = slugify(title or source.stem)

    workspace = Path(output_dir).resolve() / slug
    sections_dir = workspace / "sections"
    comments_dir = workspace / "comments"
    committee_dir = workspace / "committee"
    sections_dir.mkdir(parents=True, exist_ok=True)
    comments_dir.mkdir(parents=True, exist_ok=True)
    committee_dir.mkdir(parents=True, exist_ok=True)

    full_text_path = workspace / "full_text.md"
    full_text_path.write_text(visible_text if visible_text else content, encoding="utf-8")

    section_index = build_section_index(content, parser, fmt)
    lines = content.splitlines()
    section_texts: dict[str, str] = {}
    for section in section_index:
        raw_body = _section_lines(
            lines,
            section["start_line"],
            section["end_line"],
            zero_based=section["line_base"] == 0,
        )
        body = parser.clean_text(raw_body, keep_structure=True) if fmt != ".pdf" else raw_body
        section_texts[section["section_key"]] = body
        (sections_dir / section["file_name"]).write_text(body, encoding="utf-8")

    section_index_path = workspace / "section_index.json"
    section_index_path.write_text(
        json.dumps(section_index, indent=2, ensure_ascii=False), encoding="utf-8"
    )

    claim_map = build_claim_map(
        visible_text if visible_text else content,
        section_index,
        section_texts=section_texts,
    )
    (workspace / "claim_map.json").write_text(
        json.dumps(claim_map, indent=2, ensure_ascii=False),
        encoding="utf-8",
    )

    metadata = {
        "slug": slug,
        "title": title or source.stem,
        "source_path": str(source),
        "language": language,
        "format": fmt,
        "generated_at": datetime.now().isoformat(),
    }
    (workspace / "metadata.json").write_text(
        json.dumps(metadata, indent=2, ensure_ascii=False),
        encoding="utf-8",
    )
    write_summary_stub(workspace, metadata["title"], claim_map, section_index)
    _copy_workspace_references(workspace)
    return workspace


def main() -> int:
    parser = argparse.ArgumentParser(description="Prepare a deep-review workspace")
    parser.add_argument("input", help="Path to a .tex, .typ, or .pdf file")
    parser.add_argument(
        "--output-dir",
        default="./review_results",
        help="Parent directory for workspace output (default: ./review_results)",
    )
    args = parser.parse_args()

    workspace = prepare_workspace(args.input, output_dir=args.output_dir)
    print(f"WORKSPACE: {workspace}")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
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: 472kUpdated 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: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated 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