algorithm-cultivation · v2.0 · 2026-02-24 · sha256 72332e53c7302add
algorithm-cultivation v2.0A
Immutable. This exact content never changes and is served at /api/v1/blob/72332e53c7302add.
No tool to install first
claude plugin marketplace add https://markdownregistry.com/mp/a/art_ppxqg5tk2plkbkyg/72332e53c7302add86467ebee6c5c13507b239b479c7713669b4d6a7081f514c.json
Then /plugin install algorithm-cultivation@markdownregistry-ppxqg5tk2plkbkyg in Claude Code. It installs this exact version, the one graded A here, pinned to the commit it was graded at, and leaves it there.
---
name: algorithm-cultivation
description: Trains an X/Twitter account's algorithmic feed to surface niche-relevant content and positions the account as a thought leader. Includes browser scripts for manual operation, a full Persona Engine for identity management, and a 24/7 Algorithm Builder with LLM-powered engagement via Puppeteer. Use when a user wants to build up their algorithm, cultivate their feed for a niche, grow a fresh account, become a thought leader, or run automated engagement with AI-generated content.
license: MIT
metadata:
author: nichxbt
version: "2.0"
---
# Algorithm Cultivation & Thought Leadership
Train your X/Twitter algorithm for a specific niche. Three approaches:
1. **Browser script** — paste into DevTools console for manual sessions
2. **CLI + Persona Engine** — create personas and run from the command line
3. **24/7 Algorithm Builder** — headless Puppeteer + LLM running continuously
## Quick reference
| Goal | Solution |
|------|----------|
| Create a persona (CLI) | `xactions persona create` |
| Run 24/7 with LLM (CLI) | `xactions persona run <id>` |
| Check persona status | `xactions persona status <id>` |
| Browser console (with core.js) | `src/automation/algorithmBuilder.js` |
| Browser console (standalone) | `scripts/thoughtLeaderCultivator.js` |
| Browser console (algorithm trainer) | `src/automation/algorithmTrainer.js` |
| Persona Engine (Node.js module) | `src/personaEngine.js` |
| Algorithm Builder (Node.js module) | `src/algorithmBuilder.js` |
| Research: algorithm internals | `docs/research/algorithm-cultivation.md` |
| Research: LLM architecture | `docs/research/llm-powered-thought-leader.md` |
## Persona Engine — `src/personaEngine.js`
The Persona Engine defines a complete identity for algorithm building:
**Niche presets** (quick-start templates):
- `crypto-degen` — crypto, DeFi, web3, memecoins
- `tech-builder` — building in public, SaaS, indie hacking
- `ai-researcher` — AI/ML, LLMs, papers, agents
- `growth-marketer` — content strategy, copywriting, audience building
- `finance-investor` — stocks, markets, portfolio management
- `creative-writer` — writing craft, storytelling, books
- `custom` — define your own
**Activity patterns** (human-like schedules):
- `night-owl` — active late night, sleeps mornings
- `early-bird` — active from 5am, winds down by 10pm
- `nine-to-five` — checks before/after work, active evenings
- `always-on` — creator schedule, active throughout the day
- `weekend-warrior` — light weekdays, heavy weekends
**Engagement strategies**:
- `aggressive` — maximum growth (80 follows, 150 likes, 40 comments/day)
- `moderate` — balanced (40 follows, 80 likes, 20 comments/day)
- `conservative` — slow and safe (15 follows, 40 likes, 8 comments/day)
- `thoughtleader` — quality over quantity (20 follows, 60 likes, 30 deep comments/day)
**Key exports:**
```js
import {
createPersona, savePersona, loadPersona, listPersonas, deletePersona,
buildPersonaSystemPrompt, buildCommentPrompt, buildPostPrompt,
shouldBeActive, planSession, getSessionDuration,
NICHE_PRESETS, ACTIVITY_PATTERNS, ENGAGEMENT_STRATEGIES,
} from './personaEngine.js';
```
## Algorithm Builder — `src/algorithmBuilder.js`
24/7 headless automation powered by Puppeteer + OpenRouter LLM.
**How it works:**
1. Loads a persona config from `~/.xactions/personas/`
2. Launches headless Chrome via Puppeteer (stealth mode)
3. Plans sessions with shuffled activities based on strategy
4. Executes: search → scroll → like → comment (LLM) → follow → post (LLM) → browse
5. Takes breaks between sessions following human-like timing
6. Respects sleep hours from the activity pattern
7. Persists all state and stats to disk after each session
**LLM features:**
- Comments generated by LLM in persona's voice (via OpenRouter)
- Original posts created by LLM matching persona's niche and tone
- System prompt auto-built from persona config
- Supports any OpenRouter model (default: `google/gemini-flash-2.0`)
**Key exports:**
```js
import { startAlgorithmBuilder, runSingleSession } from './algorithmBuilder.js';
await startAlgorithmBuilder({
personaId: 'persona_1234',
authToken: 'your_auth_token',
headless: true, // false to see the browser
dryRun: false, // true to preview without executing
maxSessions: 0, // 0 = infinite
});
```
## CLI commands
```bash
# Create a persona interactively
xactions persona create
# Create with options
xactions persona create --preset crypto-degen --strategy aggressive --activity night-owl
# List all personas
xactions persona list
# Run the algorithm builder (24/7)
xactions persona run <personaId>
xactions persona run <personaId> --no-headless # visible browser
xactions persona run <personaId> --dry-run # preview mode
xactions persona run <personaId> --sessions 5 # stop after 5 sessions
# Check detailed stats
xactions persona status <personaId>
# Edit persona config
xactions persona edit <personaId> --topics "ai,llm,agents" --strategy thoughtleader
# Delete a persona
xactions persona delete <personaId>
```
## Environment variables
| Variable | Purpose |
|----------|---------|
| `OPENROUTER_API_KEY` | Required for LLM-generated comments and posts |
| `XACTIONS_SESSION_COOKIE` | X auth token (alternative to `--token` flag) |
## Browser scripts
### Full-featured: `src/automation/algorithmBuilder.js`
Requires pasting `src/automation/core.js` first. 969-line comprehensive browser automation with:
- LLM-powered comment generation (OpenRouter or any OpenAI-compatible endpoint)
- 6 activity cycles: Search & Engage, Browse Home, Target Account, Explore, Search People, Own Profile
- Weighted cycle selection with natural activity rotation
- Session/break cycling for 24/7 operation
- Peak/off-peak hour awareness
- Per-session and per-day rate limits
- Full state persistence via localStorage
**Configure:**
- `NICHE_CONFIG.KEYWORDS` — search terms for your niche
- `NICHE_CONFIG.PERSONA` — your niche identity (used for LLM persona)
- `NICHE_CONFIG.TARGET_ACCOUNTS` — accounts to engage with
- `NICHE_CONFIG.BIO_KEYWORDS` — only follow users matching these
- `LLM_CONFIG.ENABLED` — enable AI-generated comments
- `LLM_CONFIG.API_KEY` — your OpenRouter API key
- `LLM_CONFIG.MODEL` — LLM model to use
- `BEHAVIOR` — all timing, limits, and probability settings
**Controls:**
- `window.stopAlgoBuilder()` — stop after current action
- `window.algoStats()` — print all-time stats
- `window.algoReset()` — clear state and start fresh
- `window.algoConfig()` — show current configuration
### Standalone: `scripts/thoughtLeaderCultivator.js`
Zero dependencies. Paste directly into DevTools console on x.com.
**Controls:**
- `stopCultivator()` — stop after current action
- `cultivatorStatus()` — print current stats
- `cultivatorReset()` — clear all tracking data
### Algorithm Trainer: `src/automation/algorithmTrainer.js`
Requires `core.js`. Multi-niche rotation, intensity presets, cycle-based architecture.
**Controls:**
- `stopTrainer()` — stop
- `trainerStatus()` — status report
- `trainerReset()` — clear data
## Training phases
Both scripts cycle through these phases with randomized order:
1. **Search Top** — search a niche term, scroll top results, engage
2. **Search Latest** — same term, latest tab (catch fresh content)
3. **Search People** — follow qualifying accounts in the niche
4. **Home Feed** — scroll and engage to reinforce algorithm learning
5. **Influencer Visit** — visit niche leaders' profiles with boosted engagement
6. **Own Profile** — visit own profile (active user signal)
7. **Explore** — browse trending topics (normalization behavior)
8. **Idle** — dwell period simulating human rest
## Algorithm signals (by weight)
| Signal | Weight | Generated by |
|--------|--------|-------------|
| Extended dwell (>2 min on thread) | 11.0x | Scroll + read pause |
| Profile click | 4.0x | Influencer / own profile visits |
| Reply / comment | 1.0-27.0x | Comment on posts |
| Bookmark | ~1.0x | Bookmark quality content |
| Like | 0.5x | Like niche posts |
| Follow | High (graph) | Follow niche accounts |
| Search | High (intent) | Search niche keywords |
## Phase model (fresh account → thought leader)
| Phase | Days | Focus |
|-------|------|-------|
| Seeding | 1-7 | Pure consumption. Search + scroll + like + follow. |
| Engagement | 8-30 | Replies, quote tweets, early engagement on viral posts. |
| Authority | 31-90 | Original threads, community building, Spaces. |
| Maintenance | 90+ | Consistency, content creation, community stewardship. |
## 24/7 LLM-powered operation
Now fully implemented via `src/algorithmBuilder.js` + `src/personaEngine.js`.
### Architecture
```
┌─────────────────────────────────────────────────┐
│ CLI: xactions persona run │
├─────────────────────────────────────────────────┤
│ Persona Engine (personaEngine.js) │
│ ├─ Niche presets (6 built-in + custom) │
│ ├─ Activity patterns (sleep/wake schedules) │
│ ├─ Engagement strategies (limits & ratios) │
│ ├─ Session planner (shuffled activity queues) │
│ └─ State persistence (~/.xactions/personas/) │
├─────────────────────────────────────────────────┤
│ Algorithm Builder (algorithmBuilder.js) │
│ ├─ Puppeteer + stealth (headless Chrome) │
│ ├─ Human-like behavior simulation │
│ │ ├─ Variable scroll speeds │
│ │ ├─ Reading pauses (2-8s) │
│ │ ├─ Mouse movement with jitter │
│ │ ├─ Typing with per-char delay (30-100ms) │
│ │ ├─ Coffee breaks (30s-2min) │
│ │ └─ Session gaps (10-120min) │
│ ├─ Activity executor │
│ │ ├─ search (top + latest tabs) │
│ │ ├─ browse_home (For You timeline) │
│ │ ├─ like (on-topic tweets) │
│ │ ├─ follow (from search & target accounts) │
│ │ ├─ comment (LLM-generated in persona voice)│
│ │ ├─ create_post (LLM original content) │
│ │ ├─ profile_visit (targets & discovered) │
│ │ ├─ check_own_profile │
│ │ └─ check_notifications │
│ └─ Graceful shutdown (SIGINT/SIGTERM/abort) │
├─────────────────────────────────────────────────┤
│ LLM Brain (OpenRouter) │
│ ├─ Comment generation (persona-voiced) │
│ ├─ Post creation (niche-relevant) │
│ ├─ Reply threading │
│ └─ Any model: Gemini, GPT-4o, Claude, Llama │
└─────────────────────────────────────────────────┘
```
### Cost estimate
- **VPS**: $5-10/month (any VPS with Chrome support)
- **LLM API**: $3-10/month (depends on model and comment volume)
- **Total**: ~$8-20/month for 24/7 operation
### Getting started (5 minutes)
```bash
# 1. Set your OpenRouter key
export OPENROUTER_API_KEY=sk-or-v1-...
# 2. Login to X
xactions login
# 3. Create a persona
xactions persona create --preset crypto-degen --strategy thoughtleader --activity always-on
# 4. Start building (runs forever)
xactions persona run persona_1234567890
```
## Research paper
Full technical deep dive: `docs/research/algorithm-cultivation.md`
Covers:
- X's recommendation algorithm internals (SimClusters, TwHIN, scoring formula)
- Signal taxonomy (4 tiers of trainable signals)
- Human behavior simulation techniques
- Detection avoidance strategies
- Metrics and measurement framework
- Ethical considerations