Markdown · llms.txt

Using tweet-factory with Claude Code

Last updated 2026-10-11. “Claude Code Twitter” here means using the Claude Code CLI as the model that drafts posts. tweet-factory’s default provider is claude-code. It does not send your likes to a tweet-factory server, and it does not create the post on X.

What the process runs

src/llm/claudecode.ts spawns:

claude -p <prompt> --output-format json --tools "" --disallowedTools "*,mcp__*" --permission-mode dontAsk

No API key is read on that path. The command uses the claude login already on the machine. --tools "" removes built-in tools, so a tweet, article, or Notion page inside the prompt cannot make it run a shell. If claude is missing, the error tells you to install Claude Code or set TF_LLM_PROVIDER and a key. The timeout is 240 seconds. TF_LLM_MODEL is passed as claude --model when you set it.

The prompt is voiceSystem() from persona/PERSONA.md and measured stats, plus OPTIMIZER_SYSTEM built from src/rank/weights.ts. Scraped text is fenced as reference data. The model is told to return JSON and to leave scores at 0. After it returns, src/rank/score.ts fills the 0–100 number. See the tweet generator and how drafts are scored.

A run that stays on your machine

bash
tf auth
tf fetch
tf onboard
tf generate

tf generate writes drafts/YYYY-MM-DD.md and onboarding.json. Default shape: four ideas, two or three variants each. --n changes the idea count. --json prints the bundle. You publish the variant you want. OAuth scopes in src/x/auth.ts are tweet.read, users.read, like.read, bookmark.read, and offline.access. There is no write scope.

Claude Code has to be logged in on that machine, including a server you cron from. tf does not ship a Claude credential.

The optional Claude Code skill

The repo includes .claude/skills/tweet-factory/SKILL.md, triggered as /tweet-factory inside Claude Code. That skill calls tf for fetch, flush, and data, then drafts. It is optional. tf generate does not load it. An extra skill at ~/.claude/skills/twitter-algorithm-optimizer/ can replace the playbook when a person runs the skill. The binary still scores with src/rank/weights.ts.

Direct APIs, if you would rather not use Claude Code, are TF_LLM_PROVIDER=anthropic, openrouter, or openai. Temperature is 0.8 and the token cap is 8,000. Details are on LLM providers.

FAQ

Can Claude Code write tweets?

Yes, as tweet-factory’s default backend. tf generate runs claude -p with your existing Claude Code login and with tools disabled. The output is a local markdown file. You post it.

Does Claude Code post to Twitter or X for me?

No. The CLI’s X scopes are read-only. Claude Code is the language model, not an X client. Publishing stays outside tf.

Do I need an Anthropic API key?

Not for the default path. The default uses the claude CLI login. Set ANTHROPIC_API_KEY only if you switch TF_LLM_PROVIDER to anthropic.