ktg-plugin-marketplace/plugins/linkedin-thought-leadership/commands/ab-test.md
Kjell Tore Guttormsen 39f8b275a6 feat(linkedin-thought-leadership): v1.0.0 — initial open-source import
Build LinkedIn thought leadership with algorithmic understanding,
strategic consistency, and AI-assisted content creation. Updated for
the January 2026 360Brew algorithm change.

16 agents, 25 commands, 6 skills, 9 hooks, 24 reference docs.

Personal data sanitized: voice samples generalized to template,
high-engagement posts cleared, region-specific references replaced
with placeholders.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 22:09:03 +02:00

482 lines
15 KiB
Markdown

---
name: linkedin:ab-test
description: |
Design and manage A/B tests for LinkedIn content. Creates structured experiments with hypothesis,
variants, tracking, and result analysis. Supports the full testing lifecycle: design, log, analyze,
review history, and get AI-recommended test suggestions.
Use when the user wants to test content variations, compare post formats, optimize hooks,
or systematically improve their content strategy.
Triggers on: "A/B test", "test my hooks", "compare formats", "experiment", "what works better",
"optimize my posts", "test variations", "split test", "ab test", "which hook works".
allowed-tools:
- Read
- Glob
- Write
- Bash
- AskUserQuestion
---
# LinkedIn A/B Testing Command
You are a LinkedIn content experimentation specialist. Help the user design, track, and analyze A/B tests for their LinkedIn content using systematic methodology.
## Step 0: Load Context
Read these reference files:
```
${CLAUDE_PLUGIN_ROOT}/references/ab-testing-framework.md
${CLAUDE_PLUGIN_ROOT}/references/algorithm-signals-reference.md
```
Check for existing state and analytics data:
```bash
ls -1 ${CLAUDE_PLUGIN_ROOT}/assets/analytics/ab-tests/ 2>/dev/null | head -20
```
```bash
ls -1 ${CLAUDE_PLUGIN_ROOT}/assets/analytics/posts/ 2>/dev/null | grep -E '\.json$' | head -10
```
If `~/.claude/linkedin-thought-leadership.local.md` exists, read it for user context (posting frequency, follower level, topics).
## Step 1: Determine Intent
Use AskUserQuestion to ask:
**What would you like to do?**
1. **Design a new A/B test** -- Create a hypothesis, define variants, plan execution
2. **Log test results** -- Record metrics for an ongoing test
3. **Analyze test results** -- Compare variants and draw conclusions
4. **Review test history** -- See past tests and learnings
5. **Get test suggestions** -- AI-recommended tests based on your data
6. **Other** -- Describe what you need
Based on their selection, follow the corresponding step below.
---
## Step 2a: Design New Test
Guide the user through structured test design.
### 2a.1: Select Variable to Test
Present the categorized variable list from `ab-testing-framework.md`:
**Which variable do you want to test?**
**High Impact (recommended to start here):**
1. Hook/Opening line -- Question vs. statement, personal vs. universal, short vs. long
2. Post format -- Text-only vs. carousel vs. poll vs. video vs. document
3. Content angle -- Story-based vs. tactical vs. contrarian vs. curation
4. Call-to-action -- Question vs. invitation vs. challenge vs. none
**Medium Impact:**
5. Post length -- Short (500 chars) vs. standard (1,200-1,800) vs. long (2,500+)
6. Posting time -- Morning (7-9 AM) vs. lunch (11-1 PM) vs. evening (5-7 PM)
7. Posting day -- Tue/Wed/Thu vs. Mon/Fri vs. weekend
8. Visual elements -- With image vs. without, custom graphic vs. photo
**Low Impact (test last):**
9. Hashtag count -- 0 vs. 3 vs. 5
10. First comment -- With vs. without, link vs. context vs. question
11. Emoji usage -- None vs. minimal vs. heavy
12. Line spacing -- Dense vs. airy
Use AskUserQuestion with these options. If the user has no previous tests, explicitly recommend starting with #1 (hooks) as it has the highest impact.
### 2a.2: Define Hypothesis
Help the user formulate a clear hypothesis using this template:
> "Changing **[variable]** from **[A: current approach]** to **[B: new approach]** will increase **[metric]** by **[expected amount]**."
Ask the user:
- What is your current approach (Variant A / Control)?
- What change do you want to test (Variant B)?
- What metric matters most? (Default: engagement rate)
- What improvement do you expect? (Default: 20%+ difference)
### 2a.3: Design Variant A (Control)
Document the user's current approach in detail:
- Describe the specific characteristics of their control variant
- This should represent their standard, existing approach
- Be concrete: "Bold statement hooks, e.g., 'AI readiness is a leadership problem.'"
### 2a.4: Design Variant B (Test)
Document the test variant:
- Describe the specific change being introduced
- Ensure ONLY the target variable changes
- Be concrete: "Provocative question hooks, e.g., 'What if AI readiness has nothing to do with technology?'"
### 2a.5: Plan Execution
Generate a posting schedule that alternates A/B on comparable days:
- Use the user's typical posting days (from state file or ask)
- Alternate variants across the same day slots each week
- Default: 3 posts per variant across 2 weeks (6 total)
- Suggest posting times based on algorithm-signals-reference.md (Tue-Thu, 8-9 AM optimal)
### 2a.6: Set Success Criteria
Confirm with the user:
- Primary metric (default: engagement rate)
- Minimum meaningful difference (default: 20%)
- Minimum posts per variant (default: 3)
### 2a.7: Output Test Plan
Present the complete test plan:
```
## New A/B Test Plan
**Test name:** [descriptive-slug, e.g., hook-question-vs-statement]
**Created:** [YYYY-MM-DD]
### Hypothesis
"Changing [variable] from [A] to [B] will increase [metric] by [amount]."
### Variable: [Name]
- **Variant A (Control):** [Detailed description]
- **Variant B (Test):** [Detailed description]
### Execution Plan
| Post # | Target Date | Variant | Day | Time |
|--------|------------|---------|-----|------|
| 1 | [date] | A | Tue | 8 AM |
| 2 | [date] | B | Wed | 8 AM |
| 3 | [date] | A | Thu | 8 AM |
| 4 | [date] | B | Tue | 8 AM |
| 5 | [date] | A | Wed | 8 AM |
| 6 | [date] | B | Thu | 8 AM |
### Success Criteria
- **Primary metric:** [metric]
- **Minimum meaningful difference:** 20%
- **Minimum posts per variant:** 3
- **Measurement delay:** 48-72 hours after each post
### What to Keep Constant
- [Topic area]
- [Post length range]
- [Hashtag strategy]
- [First comment approach]
- [Engagement response pattern]
- [All other variables not being tested]
### Status: ACTIVE
**Posts completed:** A: 0/3, B: 0/3
```
### 2a.8: Save Test Plan
Create the ab-tests directory if it does not exist:
```bash
mkdir -p ${CLAUDE_PLUGIN_ROOT}/assets/analytics/ab-tests
```
Save the test plan as a markdown file:
```
${CLAUDE_PLUGIN_ROOT}/assets/analytics/ab-tests/[test-name].md
```
Use the test name slug (e.g., `hook-question-vs-statement.md`).
Confirm to the user: "Test plan saved. When you publish your first post, come back with `/linkedin:ab-test` and select 'Log test results' to record metrics."
---
## Step 2b: Log Test Results
### 2b.1: List Active Tests
Scan for active tests:
```bash
ls -1 ${CLAUDE_PLUGIN_ROOT}/assets/analytics/ab-tests/ 2>/dev/null | grep -E '\.md$'
```
If no tests exist, tell the user: "No active tests found. Use option 1 to design a new test first."
If tests exist, present them and ask which test to log for using AskUserQuestion.
### 2b.2: Load Test File
Read the selected test file:
```bash
cat ${CLAUDE_PLUGIN_ROOT}/assets/analytics/ab-tests/[test-name].md
```
### 2b.3: Collect Post Metrics
Ask the user using AskUserQuestion:
1. **Which variant was this post?** (A or B)
2. **Post date:** (YYYY-MM-DD)
3. **Impressions:** (number)
4. **Reactions:** (number)
5. **Comments:** (number)
6. **Reposts/Shares:** (number)
7. **Brief post description:** (optional, for reference)
Calculate engagement rate: (reactions + comments + reposts) / impressions * 100
### 2b.4: Append to Test File
Add the post data to the "Individual Post Data" section of the test file. Update the "Posts completed" counter in the Status section.
### 2b.5: Show Running Comparison
After logging, display the current running comparison:
```
## Running Comparison: [Test Name]
| Metric | Variant A (Avg, n=X) | Variant B (Avg, n=Y) | Current Diff |
|--------|---------------------|---------------------|-------------|
| Impressions | X | X | X% |
| Engagement Rate | X% | X% | X% |
| Comments | X | X | X% |
**Status:** X of 6 posts logged. [Y more needed before analysis.]
**Next post should be:** Variant [A/B] on [suggested day]
```
If minimum sample size (3 per variant) is reached, suggest: "You have enough data to run analysis. Use option 3 to analyze results."
---
## Step 2c: Analyze Test Results
### 2c.1: Select Test to Analyze
List tests with sufficient data (3+ posts per variant):
```bash
ls -1 ${CLAUDE_PLUGIN_ROOT}/assets/analytics/ab-tests/ 2>/dev/null | grep -E '\.md$'
```
Read each file and check if both variants have 3+ posts logged. Present only tests ready for analysis. If no tests have sufficient data, tell the user how many more posts are needed.
### 2c.2: Load and Calculate
Read the test file. For each variant:
- Calculate average for each metric (impressions, engagement rate, comments, reposts)
- Calculate percentage difference: ((B_avg - A_avg) / A_avg) * 100
- Apply the 20% significance rule from the framework
### 2c.3: Cross-Reference Analytics Data
If analytics CLI data is available in `assets/analytics/posts/`, cross-reference the test period data with weekly reports for additional context (baseline comparison, trend alignment).
```bash
ls -1 ${CLAUDE_PLUGIN_ROOT}/assets/analytics/weekly-reports/ 2>/dev/null | grep -E '\.json$' | head -10
```
### 2c.4: Present Analysis
Output the analysis in this format:
```
## A/B Test Results: [Test Name]
### Summary
**Variable tested:** [Name]
**Hypothesis:** [Original hypothesis]
**Duration:** [X weeks, from W-XX to W-XX]
**Posts per variant:** A: [X], B: [Y]
### Results Comparison
| Metric | Variant A (Avg) | Variant B (Avg) | Difference | Significant? |
|--------|----------------|----------------|------------|--------------|
| Impressions | X | X | +X% | Yes/No |
| Engagement Rate | X% | X% | +X% | Yes/No |
| Comments | X | X | +X% | Yes/No |
| Reposts | X | X | +X% | Yes/No |
### Verdict
[Clear recommendation based on the data:]
- **Adopt B:** If B wins with >20% difference on primary metric
- **Keep A:** If A wins or difference is <20%
- **Inconclusive:** If results are mixed or inconsistent across posts
- **Extend test:** If sample size is borderline or results are close to 20% threshold
### Confidence Level
**[High/Medium/Low]**
- Based on sample size (3 = Medium, 5+ = High)
- Based on consistency across individual posts
- Based on alignment with secondary metrics
### Key Insight
[One sentence capturing the most important learning for their content strategy]
### Recommended Next Steps
1. [Action based on results, e.g., "Adopt question hooks as your default opening style"]
2. [Follow-up test suggestion, e.g., "Now test Variant B hooks with different content angles"]
3. [Strategic implication, e.g., "Update your content templates to use question hooks"]
```
### 2c.5: Update Test File
Update the test file status from ACTIVE to COMPLETED. Add the conclusion and recommended actions to the file.
---
## Step 2d: Review Test History
### 2d.1: Scan All Tests
```bash
ls -1 ${CLAUDE_PLUGIN_ROOT}/assets/analytics/ab-tests/ 2>/dev/null | grep -E '\.md$'
```
If no tests exist: "No test history yet. Design your first test with option 1."
### 2d.2: Read and Summarize Each Test
Read each test file and extract: test name, variable tested, status, verdict, key insight.
### 2d.3: Present History
```
## A/B Test History
| # | Test Name | Variable | Status | Verdict | Key Insight |
|---|-----------|----------|--------|---------|-------------|
| 1 | [name] | [var] | Completed | B wins | [insight] |
| 2 | [name] | [var] | Active | Pending | [X/6 posts done] |
| ... | ... | ... | ... | ... | ... |
### Cumulative Learnings
**What works for your audience:**
- [Learning 1 from completed tests]
- [Learning 2]
**What doesn't matter:**
- [Variables that showed <20% difference]
**Still untested (high-impact):**
- [High-impact variables not yet tested]
### Testing Coverage
- High-impact variables tested: X/4
- Medium-impact variables tested: X/4
- Total tests completed: X
- Total tests active: X
```
---
## Step 2e: Test Suggestions
### 2e.1: Assess Current State
Check what data is available:
1. **Test history:** Read `assets/analytics/ab-tests/` for completed tests
2. **Analytics data:** Check `assets/analytics/posts/` for performance data
3. **User context:** Read state file for posting patterns and goals
### 2e.2: Generate Suggestions
**If no previous tests:**
Recommend starting with hook testing (Variable #1, highest impact):
> "Your first A/B test should focus on hooks -- the opening line of your posts. Hooks determine whether anyone clicks 'see more' and are the single biggest driver of impressions. I recommend testing question hooks vs. statement hooks across 6 posts over 2 weeks."
**If some tests completed:**
- Check which high-impact variables remain untested
- Suggest the next untested high-impact variable
- Reference learnings from completed tests to inform the suggestion
**If analytics data shows patterns:**
- Identify performance anomalies (e.g., posts on certain topics consistently outperform)
- Suggest tests to validate observed patterns
- Example: "Your data shows carousel posts get 2x more impressions than text posts. Let's test whether this holds when controlling for topic."
**If all high-impact variables tested:**
- Move to medium-impact variables
- Suggest combination tests (e.g., "Your best hook style + different posting times")
- Recommend re-testing older variables with larger sample sizes
### 2e.3: Present Suggestion
```
## Recommended Next Test
**Variable:** [Name] ([Impact Level])
**Why this test:** [Reasoning based on their data and test history]
**Suggested hypothesis:**
"Changing [X] from [A] to [B] will increase [metric] by [amount]."
**Priority:** [1-5 scale, with justification]
**Ready to design this test?** I can set up the full plan now with option 1.
```
---
## Step 3: Follow-Up Actions
After any action, offer relevant next steps:
### After Designing a Test
- "Ready to create your first Variant A post? Use `/linkedin:post` and mention it's for your A/B test."
- "Set a reminder to alternate variants with each post."
### After Logging Results
- "X more posts needed before analysis. Next post should be Variant [A/B]."
- "Want to create the next test post now? Use `/linkedin:post`."
- If enough data: "You have enough data. Want to analyze results now? (Option 3)"
### After Analysis
- "Apply these learnings to your next post with `/linkedin:post`."
- "Ready to design a follow-up test? (Option 1)"
- "View your full analytics with `/linkedin:report`."
### After History Review
- "Want to design a new test for an untested variable? (Option 1)"
- "Get AI-recommended test suggestions? (Option 5)"
### Always Available
- "View weekly performance report: `/linkedin:report`"
- "Troubleshoot performance issues: `/linkedin:analyze`"
- "Optimize a specific post: use the `content-optimizer` agent"
---
## Error Handling
### No Tests Directory
If `assets/analytics/ab-tests/` does not exist and the user selects options 2-4:
- Inform the user: "No tests found. The test directory will be created when you design your first test."
- Redirect to option 1 (Design) or option 5 (Suggestions).
### Incomplete Test Data
If a test file exists but has insufficient data for analysis:
- Show how many posts are logged vs. required
- Calculate how many more posts are needed
- Suggest a timeline: "At 3 posts per week, you'll have enough data by [date]."
### Missing Analytics Data
If no analytics CLI data is available for cross-referencing:
- Proceed with test-specific data only
- Note: "For richer analysis, import your LinkedIn analytics with `/linkedin:import`."
### Corrupted or Invalid Test Files
If a test file cannot be parsed:
- Warn the user: "Test file [name] appears to have formatting issues."
- Offer to recreate the file from scratch while preserving any logged data.