feat(linkedin): integrate state-updater.mjs across all commands and hooks

Replace manual YAML editing instructions with deterministic
state-updater.mjs calls in 8 content commands (post, quick, react,
pipeline, first-post, video, publish, carousel) and 2 hook prompts
(state-update-reminder, post-creation-automation). Batch.md gets note
that state updates happen at publish time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-04-11 00:42:17 +02:00
commit 1474948ef8
11 changed files with 141 additions and 72 deletions

View file

@ -152,7 +152,7 @@ Ask if they want to:
After approval:
- Confirm all drafts are saved and queued
- Update state file with planned topics
- Update state file with planned topics (note: state updates for batch posts happen at publish time via `/linkedin:publish`, not at batch creation)
- Show queue summary:
```

View file

@ -192,6 +192,17 @@ Offer refinement options as text (no interactive prompt):
## Step 7: State Update
If the user confirms the carousel is ready:
- Note in state file: topic, format=carousel, slide count
- Suggest: "After publishing, run the 5x5x5 engagement method for maximum reach."
If the user confirms the carousel is ready, update state deterministically:
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'Hook text here...',
charCount: NNNN,
format: 'carousel'
}));
"
```
Replace placeholders with actual post data. Suggest: "After publishing, run the 5x5x5 engagement method for maximum reach."

View file

@ -145,13 +145,20 @@ Then present: "Post copied to clipboard. Go to linkedin.com, click 'Start a post
## Step 7: State Update
After finalizing:
- Set `first_post_date` to today (YYYY-MM-DD) — this is the most important update
- Set `last_post_date` to today
- Set `last_post_topic` to the topic
- Set `posts_this_week` to 1 (or increment if week matches)
- Set `current_streak` to 1
- Add entry to "## Recent Posts"
After finalizing, update state deterministically (this also sets `first_post_date` automatically):
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'Hook text here...',
charCount: NNNN,
format: 'post'
}));
"
```
Replace placeholders with actual post data. `first_post_date` is set automatically when null.
## Step 8: Next Steps

View file

@ -182,13 +182,20 @@ After 48 hours, run `/linkedin:analyze` to review:
## State Update
After pipeline completes, update `~/.claude/linkedin-thought-leadership.local.md`:
- Set `last_post_date` to today
- Set `last_post_topic` to the topic
- Increment `posts_this_week`
- Update streak
- Add to Recent Posts
- Set `next_planned_topic` if discussed
After pipeline completes, update state deterministically:
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'Hook text here...',
charCount: NNNN,
format: 'pipeline'
}));
"
```
Replace placeholders with actual post data. Set `next_planned_topic` manually if discussed.
## Reference Files

View file

@ -173,14 +173,20 @@ Before they post, remind them:
- Target: 15+ engagements in first hour
**State Update:**
After the post is finalized, update `~/.claude/linkedin-thought-leadership.local.md`:
- Set `last_post_date` to today's date (YYYY-MM-DD)
- Set `last_post_topic` to the main topic
- Check if ISO week changed — if so, reset `posts_this_week` to 0, update `current_week`
- Increment `posts_this_week`
- Update streak: increment if consecutive day, reset to 1 if gap > 2 days
- Update `longest_streak` if current exceeds it
- Add entry to "## Recent Posts": [YYYY-MM-DD] "Hook text..." (char count) - topic
After the post is finalized, update state deterministically:
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'Hook text here...',
charCount: NNNN,
format: 'post'
}));
"
```
Replace placeholders with actual post data. This replaces manual YAML editing.
## Reference Files

View file

@ -65,15 +65,20 @@ node --input-type=module -e "import { queueUpdateStatus } from '${CLAUDE_PLUGIN_
## Step 5: Update State File
Update `~/.claude/linkedin-thought-leadership.local.md`:
- Set `last_post_date` to today (YYYY-MM-DD)
- Set `last_post_topic` to the post's pillar/topic
- If `first_post_date` is null, set to today (set ONCE, never changed)
- Check if ISO week changed — if so, reset `posts_this_week` to 0 and update `current_week`
- Increment `posts_this_week`
- Update streak: increment `current_streak` if posting on consecutive days, reset to 1 if gap > 2 days
- Update `longest_streak` if current exceeds it
- Add entry to `## Recent Posts` section
Update state deterministically:
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'Hook text here...',
charCount: NNNN,
format: 'FORMAT'
}));
"
```
Replace placeholders with actual post data from the published post.
## Step 6: First-Hour Engagement Reminders

View file

@ -150,12 +150,20 @@ Then confirm: "Copied to clipboard."
Do NOT proactively offer alternative versions. Only generate alternatives if the user asks.
**State Update:**
After the post is finalized, update `~/.claude/linkedin-thought-leadership.local.md`:
- Set `last_post_date` to today's date (YYYY-MM-DD)
- Set `last_post_topic` to the main topic
- Check if ISO week changed — if so, reset `posts_this_week` to 0, update `current_week`
- Increment `posts_this_week`
- Update streak and add entry to "## Recent Posts"
After the post is finalized, update state deterministically:
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'Hook text here...',
charCount: NNNN,
format: 'quick'
}));
"
```
Replace placeholders with actual post data. This replaces manual YAML editing.
## Common Mistakes to Avoid

View file

@ -148,14 +148,20 @@ Wait for the user to respond naturally.
## Step 8: State Update
After the post is finalized, update `~/.claude/linkedin-thought-leadership.local.md`:
- Set `last_post_date` to today's date (YYYY-MM-DD)
- Set `last_post_topic` to the main topic
- Check if ISO week changed — if so, reset `posts_this_week` to 0, update `current_week`
- Increment `posts_this_week`
- Update streak: increment if consecutive day, reset to 1 if gap > 2 days
- Update `longest_streak` if current exceeds it
- Add entry to "## Recent Posts": [YYYY-MM-DD] "Hook text..." (char count) - topic
After the post is finalized, update state deterministically:
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'Hook text here...',
charCount: NNNN,
format: 'react'
}));
"
```
Replace placeholders with actual post data. This replaces manual YAML editing.
---
@ -245,7 +251,7 @@ Offer same refinement options as Step 7.
### Step 8b: State Update
Same as Step 8 — update state file with topic, increment counts, etc.
Same as Step 8 — run `state-updater.mjs` with actual post data.
---

View file

@ -202,12 +202,20 @@ Before you record:
```
**State Update:**
After the script is finalized, update `~/.claude/linkedin-thought-leadership.local.md`:
- Set `last_post_date` to today's date
- Check if ISO week changed — if so, reset `posts_this_week` to 0, update `current_week`
- Increment `posts_this_week`
- Update streak: increment if consecutive day, reset to 1 if gap > 2 days
- Add to "Recent Posts": `[YYYY-MM-DD] "Hook text..." [VIDEO/type/length] - topic`
After the script is finalized, update state deterministically:
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'Hook text here...',
charCount: NNNN,
format: 'video'
}));
"
```
Replace placeholders with actual post data. This replaces manual YAML editing.
## Reference Files

View file

@ -19,7 +19,7 @@ Based on the day of the week, suggest the next optimal posting window:
Remind: 'Before posting, spend 15-20 minutes on 5x5x5 pre-engagement: find 5 people with overlapping audiences, comment thoughtfully on their recent posts.'
**4. Content Logging**
Note: The post topic and hook should be logged to the state file when the session ends (handled by Stop hook).
Note: State tracking is handled deterministically by `state-updater.mjs` via the Stop hook. Do not manually edit the state file YAML frontmatter.
**5. Voice Sample Suggestion**

View file

@ -1,23 +1,34 @@
Before ending this LinkedIn content session, do two things:
**1. Update State File**
If a post was created or finalized in this session, update `~/.claude/linkedin-thought-leadership.local.md`:
- Set `last_post_date` to today (YYYY-MM-DD format)
- Set `last_post_topic` to the main topic (use the matching `expertise_areas` value when possible for consistent pillar tracking)
- If `first_post_date` is null and a post was created, set `first_post_date` to today (YYYY-MM-DD). This is set ONCE and never changed after that.
- Check if ISO week has changed — if so, reset `posts_this_week` to 0 and update `current_week`
- Increment `posts_this_week`
- Update streak: increment `current_streak` if posting on consecutive days (gap <= 1 day), reset to 1 if gap > 2 days
- Update `longest_streak` if current exceeds it
- Add entry to '## Recent Posts' section: [YYYY-MM-DD] "Hook text..." (char count) - topic_area (use expertise_area name for consistent pillar tracking)
If a post was created or finalized in this session, use the state-updater script:
```bash
node --input-type=module -e "
import { writeState, updatePostTracking } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updatePostTracking(content, {
postDate: 'YYYY-MM-DD',
postTopic: 'topic_area',
hookText: 'First 60 chars of hook...',
charCount: NNNN,
format: 'post'
}));
"
```
Replace the placeholder values with actual post data from this session.
If the user mentioned or updated their follower count during this session:
```bash
node --input-type=module -e "
import { writeState, updateFollowerCount } from '${CLAUDE_PLUGIN_ROOT}/hooks/scripts/state-updater.mjs';
writeState(content => updateFollowerCount(content, {
count: NNNN,
month: 'YYYY-MM'
}));
"
```
- Clear `next_planned_topic` if it was used, or set it to the next suggested topic
- If analytics data was imported in this session, set `last_import_date` to today (YYYY-MM-DD) and `last_import_week` to current ISO week (YYYY-WXX)
- If the user mentioned or updated their follower count during this session:
- Update `follower_count` to the new value
- If the month changed since last monthly_growth entry, append: {month: "YYYY-MM", count: X, delta: X}
- Recalculate `growth_rate_needed`: (follower_target - follower_count) / months_remaining
- Recalculate `projected_10k_date` from average of last 3 monthly deltas
- Add entry to '## Milestone Log': [YYYY-MM] count (+delta)
**2. Pre-Publish Reminders** (only if a post was created)