Reddit ICP监控器 是做什么的?
监控子版块中描述你解决的问题的用户。对其相关性进行评分。为每个匹配的帖子起草一份有用的回复。
关键规则: 切勿发明帖子URL、标题或内容。输出中的每个帖子都必须来自Reddit搜索结果。如果某个部分没有结果,标记为“未找到匹配项。”切勿为搜索结果未返回的帖子起草回复。
反垃圾规则: 除非帖子明确要求工具推荐,否则起草的回复不得提及你的产品或公司名称。听起来像从业者,而不是营销人员。
第一步:设置检查
echo "GEMINI_API_KEY: ${GEMINI_API_KEY:+set}"
echo "REDDIT_CLIENT_ID: ${REDDIT_CLIENT_ID:-未设置,使用公共端点(10 RPM)}"
如果缺少 GEMINI_API_KEY: 停止。告知用户:“需要 GEMINI_API_KEY。请在 aistudio.google.com 获取。将其添加到您的 .env 文件中。”
如果缺少 Reddit 凭据: 继续。使用 Reddit 的公共 JSON 端点(无需认证,限制为 10 RPM)。对于大多数包含 3-6 个子版块搜索的监控会话,这已经足够。
如果设置了 REDDIT_CLIENT_ID: 使用 OAuth 以获得 60 RPM。首先获取令牌:
TOKEN=$(curl -s -X POST \
-d "grant_type=password&username=$REDDIT_USERNAME&password=$REDDIT_PASSWORD" \
--user "$REDDIT_CLIENT_ID:$REDDIT_CLIENT_SECRET" \
-H "User-Agent: varnan-skills/1.0" \
https://www.reddit.com/api/v1/access_token \
| python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])")
在后续所有请求中使用 Authorization: Bearer $TOKEN 和 https://oauth.reddit.com 基本 URL。
第二步:加载ICP
检查是否存在ICP文件:
ls docs/icp.md 2>/dev/null && echo "找到 icp" || echo "缺少 icp"
如果存在 docs/icp.md: 读取它。提取:
product:一句话的产品描述pain_points:痛点短语列表(精确买家语言)anti_keywords:排除帖子的短语subreddits:要搜索的子版块列表
如果 docs/icp.md 不存在: 询问这3个问题。在全部回答之前不要继续:
- 你的产品是做什么的?(一句话)
- 你的ICP在哪些子版块发帖?(逗号分隔,例如 devops, startups, SaaS)
- 哪些痛点短语应该触发匹配?(3-5个短语,用买家自己的话,例如“onboarding takes forever”、“can't see why users churn”)
收集答案后,按照 references/icp-format.md 中的规范格式保存到 docs/icp.md。确认:“ICP已保存到 docs/icp.md。在以后的运行中将自动使用。”
阅读 references/icp-format.md 以了解规范格式以及好的和坏的痛点短语示例。
第三步:搜索Reddit
对于每个子版块和痛点短语的组合,执行一次搜索。除非设置了OAuth凭据,否则使用公共端点。
不带OAuth(公共端点):
curl -s \
-H "User-Agent: varnan-skills/1.0" \
"https://www.reddit.com/r/{SUBREDDIT}/search.json?q={PHRASE}&sort=new&t=week&limit=25&restrict_sr=true" \
| python3 -c "
import sys, json
d = json.load(sys.stdin)
posts = d.get('data', {}).get('children', [])
for p in posts:
data = p['data']
print(json.dumps({
'id': data['id'],
'title': data['title'],
'body': data.get('selftext', '')[:600],
'url': 'https://reddit.com' + data['permalink'],
'score': data['score'],
'comments': data['num_comments'],
'subreddit': data['subreddit'],
'created_utc': data['created_utc']
}))
"
带OAuth:
将 https://www.reddit.com 替换为 https://oauth.reddit.com,并添加 -H "Authorization: Bearer $TOKEN"。
在将短语插入查询字符串之前进行URL编码:
ENCODED=$(python3 -c "import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "{PHRASE}")
时间窗口默认值:
- 默认值:
t=week(最近7天) - 用户说“today”或“last 24 hours”:
t=day - 用户说“this month”:
t=month
所有搜索完成后:
- 将所有帖子收集到一个列表中
- 按帖子ID去重。如果同一帖子匹配多个短语,保留一次并记录所有匹配的短语。
- 如果搜索返回0个帖子:记录下来并继续。不要停止。
在评分前说明总候选数:“在Y个子版块中找到X个候选帖子。”
第四步:使用Gemini评分相关性
将所有候选帖子和ICP上下文写入临时文件,然后评分:
cat > /tmp/reddit-score-request.json << 'ENDJSON'
{
"system_instruction": {
"parts": [{
"text": "You are a GTM analyst identifying Reddit posts where someone is experiencing the exact pain point that a specific product solves. For each post provided, output a JSON object with these fields: id (the post id), score (integer 1-5), reason (one sentence explaining the score). Scoring rubric: 5 = person clearly has the problem AND is actively seeking help or venting frustration about it; 4 = strong signal, problem is present but less explicit; 3 = possible match, uncertain; 2 = tangentially related but not the core pain; 1 = unrelated. Output only a JSON array of score objects. No commentary before or after the array."
}]
},
"contents": [{
"parts": [{
"text": "POSTS_AND_ICP_CONTEXT_HERE"
}]
}],
"generationConfig": {
"temperature": 0.2,
"maxOutputTokens": 2048
}
}
ENDJSON
curl -s -X POST \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d @/tmp/reddit-score-request.json \
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d['candidates'][0]['content']['parts'][0]['text'])"
将 POSTS_AND_ICP_CONTEXT_HERE 替换为:
- 步骤2中的产品描述和痛点短语
- 每个候选帖子:id、标题、正文片段
- ICP中的排除关键词(Gemini应将它们评分较低)
仅保留评分 >= 4 的帖子用于回复起草。
说明:“有X个帖子获得4或5分。正在起草回复。”
如果0个帖子评分 >= 4:输出步骤7中的零结果消息并停止。不要起草空回复。
第五步:使用Gemini起草回复
在起草前阅读 references/reply-rules.md。为每个高分帖子确定帖子类型(模式1、2或3),并将模式传递给Gemini。
对于每个评分 >= 4 的帖子,起草回复(每个会话最多5个回复):
cat > /tmp/reddit-reply-request.json << 'ENDJSON'
{
"system_instruction": {
"parts": [{
"text": "You are a practitioner who has personally solved the exact problem being described in this Reddit post. Write a helpful reply that: (1) directly addresses what the person asked or is frustrated about, (2) shares a specific, useful insight from real experience, (3) does NOT mention any product, tool, or company by name unless the post explicitly asks for tool recommendations, (4) is 2-5 sentences, written in plain conversational prose with no headers or bullet lists, (5) optionally ends with a low-pressure invitation to continue the conversation. Do not use marketing language. Do not use these words: game-changer, best-in-class, streamline, transform, revolutionize, leverage, seamless, robust, comprehensive, innovative. Sound like a real person."
}]
},
"contents": [{
"parts": [{
"text": "POST_CONTENT_AND_MODE_HERE"
}]
}],
"generationConfig": {
"temperature": 0.7,
"maxOutputTokens": 512
}
}
ENDJSON
curl -s -X POST \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d @/tmp/reddit-reply-request.json \
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d['candidates'][0]['content']['parts'][0]['text'])"
将 POST_CONTENT_AND_MODE_HERE 替换为:
- 完整的帖子标题和正文
- 回复模式(模式1:发泄/沮丧,模式2:如何处理X,模式3:工具推荐)
- 产品描述(以便Gemini在模式1/2中知道避免命名什么)
- 如果是模式3:Gemini可以命名产品,并且必须命名一个替代品
第六步:自我QA
在呈现之前执行每一项检查并修复违规:
- 模式1或模式2的回复中不出现产品名称
- 任何回复中不出现禁用词:“game-changer”、“best-in-class”、“streamline”、“transform”、“revolutionize”、“leverage”、“seamless”、“robust”、“innovative”
- 每个回复2-5个句子(计数并说明)
- 每个回复直接回应帖子中的特定问题或沮丧
- 输出中的所有URL都是来自搜索结果的真实Reddit URL(不是构造或猜测的)
- 总共起草的回复不超过5个
- 模式3的回复至少提到一个替代品(不仅仅是本产品)
- 如果任何子版块在所有关键词搜索中返回0个结果,在输出中标记它
在呈现前修复任何违规。
第七步:输出和保存
呈现完整报告:
## Reddit ICP监控器 — [YYYY-MM-DD]
**监控的子版块:** r/[subreddit1]、r/[subreddit2]
**时间窗口:** 最近7天
**搜索的关键词:** [phrase1]、[phrase2]、[phrase3]
**找到的候选帖子:** X 个
**高信号匹配项(评分4-5):** Y 个
---
### 匹配项1 — 评分 [N]/5
**帖子:** [标题](url)
**子版块:** r/[subreddit] | [N] 票 | [N] 评论
**信号引用:** "[帖子正文的相关摘录]"
**匹配的关键词:** [phrase]
**帖子类型:** 模式 [1/2/3]
**起草的回复:**
[回复文本]
**回复字数:** N 字
---
[对每个匹配项重复]
---
**返回0结果的子版块:** [列出任何没有返回结果的子版块]
如果0个帖子评分 >= 4: “在过去7天内,在 [子版块] 中未找到高信号匹配项。搜索的关键词:[列出]。尝试扩大时间窗口(重新运行并说‘last month’)或拓宽 docs/icp.md 中的痛点短语。”
保存到文件:
mkdir -p docs/reddit-intel
OUTFILE="docs/reddit-intel/$(date +%Y-%m-%d).md"
cat > "$OUTFILE" << 'EOF'
REPORT_CONTENT_HERE
EOF
echo "已保存到 $OUTFILE"