Skip to content

[claude-hackernews] Reconcile drafts/ vs comments/ split; add cron no-op alert#4

Merged
NiveditJain merged 1 commit into
mainfrom
luv-5
Apr 30, 2026
Merged

[claude-hackernews] Reconcile drafts/ vs comments/ split; add cron no-op alert#4
NiveditJain merged 1 commit into
mainfrom
luv-5

Conversation

@NiveditJain
Copy link
Copy Markdown
Member

@NiveditJain NiveditJain commented Apr 30, 2026

Summary

The hourly cron was completing OK on Discord but not opening any PRs. Root cause: instructions disagreed about where writes go and whether to PR.

Source Folder Commit / push / PR?
README.md (added in PR #3) comments/<ts>.md yes, four steps
LUV_PROMPT in hourly_hackernews_cron.py comments/<ts>.md yes
CLAUDE.md "Drafts only (never post)" drafts/<ts>.md no
INSTRUCTIONS.md "Writes (drafts only)" drafts/<ts>.md no

The agent reads CLAUDE.md as binding always-on rules, so it would write a drafts/ file in the luv clone and stop -- never committing or pushing -- and the cron's "ok" event fired regardless because rc=0 was the only completion signal. PR #3 explicitly flagged this divergence as a follow-up; this is that follow-up.

Changes

  • CLAUDE.md: "Drafts only (never post)" -> "Comments via PR (never direct post)". Adds the four-step PR workflow inline. Drops drafts-as-pending-state language; the PR's open/merged state is the source of truth.
  • INSTRUCTIONS.md: "Writes (drafts only)" -> "Writes (comments via PR)". Step 6 saves to comments/, step 7 is the commit/push/PR flow. Three-surface coverage check becomes two-surface (drops drafts/). Inert composer-recipe header updated.
  • .gitignore: re-adds drafts/ (was un-ignored in PR [claude-hackernews] Switch HN automation to drafts-only mode #2).
  • drafts/.gitkeep: removed.
  • scripts/hourly_hackernews_cron.py: new _snapshot_pr_numbers helper. Cron snapshots PR numbers on GH_REPO before and after _run_luv. On rc=0, posts green "ok" only if a new PR appeared (PR URL in the body); otherwise posts a yellow "noop" embed so silent dead-ends are visible. If the gh query fails on either snapshot, the run downgrades to noop rather than risk a false-positive new-PR claim.

Test plan

  • Re-read updated CLAUDE.md "Comments via PR (never direct post)" -- check the four-step workflow is unambiguous.
  • Re-read updated INSTRUCTIONS.md "Writes (comments via PR)" steps 6 and 7 -- verify the comment file format and the PR command form match the existing convention ([claude-hackernews] ... titles).
  • grep -rn 'drafts/' CLAUDE.md INSTRUCTIONS.md README.md scripts/ .gitignore -- only .gitignore should match.
  • Smoke-test cron manually with CRON_FORCE=1 python3 scripts/hourly_hackernews_cron.py against a known fresh thread -- expect green "ok" Discord embed with PR URL.
  • Smoke-test no-op detection with a deliberately useless prompt -- expect yellow "noop" embed.
  • Wait for the next real hourly cron tick after merge and confirm Discord reflects the new lifecycle.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated repository ignore patterns.
    • Transitioned comment submission workflow from drafts to GitHub PR-based approvals.
    • Enhanced automation to track and report newly opened GitHub PRs.
    • Updated documentation to reflect the new comment submission process.

…-op alert

Why the cron was firing OK with no PR: README.md (PR #3) said
comments/ + commit/push/PR; CLAUDE.md and INSTRUCTIONS.md said
drafts/<ts>.md with no Git steps. The agent reads CLAUDE.md as the
binding always-on rules, so it would write a drafts/ file in the luv
clone and stop -- never committing or pushing -- and the cron's "ok"
event fired regardless because rc=0 was the only completion signal.

Changes:
- CLAUDE.md "Drafts only (never post)" -> "Comments via PR (never
  direct post)". Folder is comments/<utc-timestamp>.md. Adds the
  four-step PR workflow inline so the always-on rules now match
  README.md and the cron prompt. Drops drafts-as-pending-state
  language; the PR open/merged state is the source of truth.
- INSTRUCTIONS.md "Writes (drafts only)" -> "Writes (comments via PR)".
  Step 6 saves to comments/, step 7 is the four-step PR flow. The
  three-surface coverage check becomes two-surface (drops drafts/).
  Inert composer recipe section header updated to match.
- .gitignore re-adds drafts/ (was un-ignored in PR #2).
- drafts/.gitkeep removed.
- scripts/hourly_hackernews_cron.py: snapshot PR numbers on GH_REPO
  before and after _run_luv. On rc=0, post green "ok" only if a new
  PR appeared (with PR URL in the body); otherwise post a yellow
  "noop" embed so silent dead-ends are visible. If the gh query
  fails on either snapshot, the run downgrades to noop rather than
  risk a false-positive new-PR claim.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@NiveditJain NiveditJain merged commit 0057af7 into main Apr 30, 2026
1 check was pending
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 42c94fd8-f5e9-448b-b193-1792f0770cd7

📥 Commits

Reviewing files that changed from the base of the PR and between ec27245 and 8c3959e.

📒 Files selected for processing (5)
  • .gitignore
  • CLAUDE.md
  • INSTRUCTIONS.md
  • drafts/.gitkeep
  • scripts/hourly_hackernews_cron.py

📝 Walkthrough

Walkthrough

The pull request transitions the Hacker News interaction workflow from a "drafts-only" model to a "comments via PR" model. Changes include excluding drafts/ in .gitignore, updating workflow documentation in CLAUDE.md and INSTRUCTIONS.md, and adding PR number tracking to the hourly cron job with Discord notifications.

Changes

Cohort / File(s) Summary
Workflow Documentation
CLAUDE.md, INSTRUCTIONS.md
Updated HN interaction workflow from drafts-only to comments-via-PR approach. Comments now written to comments/<utc-timestamp>.md files, committed on fresh branches, pushed, and opened as PRs for approval gates. Duplicate checking now scans comments/ on current branch and open PRs instead of drafts/.
Cron Automation
scripts/hourly_hackernews_cron.py
Added PR number tracking via new _snapshot_pr_numbers() helper function. Cron job now snapshots GitHub PR state before and after running luv, computes newly opened PRs, and includes PR URLs in success Discord embeds. Sends noop embed when no new PRs are created.
Version Control Configuration
.gitignore
Added drafts/ directory to ignore patterns.

Sequence Diagram

sequenceDiagram
    participant Cron as Hourly Cron
    participant GH as GitHub (gh CLI)
    participant Luv as Luv Tool
    participant Discord as Discord Webhook

    Cron->>GH: Snapshot existing PR numbers (before)
    alt gh CLI available
        GH-->>Cron: Set of PR numbers or None
    else
        GH-->>Cron: None (unavailable/timeout/error)
    end
    
    Cron->>Luv: Run luv workflow
    alt luv succeeds
        Luv-->>Cron: Exit 0
    else
        Luv-->>Cron: Non-zero exit
        Cron->>Discord: Send fail embed
        Cron->>Cron: Return error code
    end
    
    Cron->>GH: Snapshot existing PR numbers (after)
    alt gh CLI available
        GH-->>Cron: Set of PR numbers or None
    else
        GH-->>Cron: None (unavailable/timeout/error)
    end
    
    Cron->>Cron: Compute new_prs = prs_after - prs_before
    
    alt new_prs exist and snapshots valid
        Cron->>Discord: Send ok embed with PR URLs
    else
        Cron->>Discord: Send noop embed (yellow)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 No more drafts in ~/drafts, dear friend,
Now PRs open—our new workflow trend!
GitHub snapshots before and after run,
Discord embeds tell when new PRs are done! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch luv-5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

NiveditJain added a commit that referenced this pull request May 1, 2026
…it prompt (#5)

Why no comment PRs were appearing despite PR #4: the cron's prompt
deferred all operational detail to README.md ("Follow the strict comment
workflow in README.md") and let the agent in each luv clone infer how to
discover threads, what commit-message format to use, what to put in the
PR body, and how to surface the result. The agent dutifully read README,
then either got stuck on discovery or stopped short of all four steps.
Cron's noop alert from PR #4 made the dead-ends visible but didn't fix
the underlying ambiguity.

Cross-checked against the sibling repo: claude-reddit's
hourly_reddit_cron.py has been producing one comment-draft PR per cron
tick reliably (12 comment files, 30 PRs, including hourly drafts like
"[claude-reddit] draft: r/<sub> - <topic>"). Its prompt is ~3x denser
and inlines every step. Mirrored that structure here with HN-appropriate
substitutions:

- "DRAFT-ONLY MODE" -> "COMMENTS-VIA-PR MODE" (HN moved past drafts-only
  in PR #4; CLAUDE.md and INSTRUCTIONS.md now use the comments-via-PR
  language).
- Reddit "search or sub feed" -> HN feed list "/news, /newest, /ask,
  /show, hn.algolia.com search, /from?site=..." (straight from
  INSTRUCTIONS.md "Where to look").
- "INSTRUCTIONS.md step 9" -> "INSTRUCTIONS.md Writes-comments-via-PR
  step 6" (the HN file-save step).
- Commit message format: [claude-hackernews] draft: <short topic>.
- Kept verbatim: ASCII-only punctuation reminder, one-draft-one-commit-
  one-PR anti-batching rule, final-reply surface instruction.

Verification:
- Python file parses (ast.parse passes).
- New default prompt resolves to 943 chars (was ~520).
- The prompt override variable still works (the new constant is the
  default for _env_str).
- Smoke test: run with the force-flag override during HN working hours
  with an Operating Chrome session logged in; the run should produce a
  comment-file + commit + push + PR end-to-end.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This was referenced May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant