.agents/skills/reddit-api/SKILL.md
Interact with the Reddit API from server-side code. Use when reading user info, submitting posts/comments, setting flair, or accessing subreddit data.
npx skillsauth add vigneshksaithal/binarygrid use-reddit-apiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
All code must follow the Coding Principles in AGENTS.md (functional, minimal, readable, modular).
import { reddit, context } from '@devvit/web/server'
| Variable | Type | Available when |
|----------|------|----------------|
| context.userId | string \| undefined | User is logged in |
| context.postId | string \| undefined | Inside a post |
| context.subredditId | string | Always |
| context.subredditName | string | Always |
Always guard optional context before use (see api-route skill for guard helpers).
const user = await reddit.getCurrentUser()
if (!user) {
return c.json({ status: 'error', message: 'Not logged in' }, 400)
}
const username = user.username
const subreddit = await reddit.getCurrentSubreddit()
const post = await reddit.submitCustomPost({
subredditName: context.subredditName!,
title: 'My Post Title',
entry: 'default', // matches entrypoint key in devvit.json
})
// post.id is the new post ID (e.g. "t3_abc")
await reddit.submitComment({
postId: context.postId!,
text: 'Great job! 🎉',
})
await reddit.setUserFlair({
subredditName: context.subredditName!,
username: user.username,
text: 'Champion 🏆',
})
When a menu item handler needs to redirect the user to a post:
app.post('/internal/menu/create-game', async (c) => {
const post = await reddit.submitCustomPost({
subredditName: context.subredditName!,
title: 'New Game',
entry: 'default',
})
return c.json({
navigateTo: `https://reddit.com/r/${context.subredditName}/comments/${post.id}`,
})
})
api-route skill pattern (try/catch, instanceof Error)src/server/__tests__/ using bun:test and devvit-mockssrc/server/)context.userId and context.postId guarded before useapi-route skill{ navigateTo: url } when redirectingbun run test passes with zero failuresdevelopment
Test-Driven Development workflow using Vitest + @devvit/test. Use when writing any new feature, fixing bugs, or refactoring existing code.
tools
Create a Svelte 5 component with optional data fetching. Use when adding UI components, views, interactive elements, or wiring client-side fetch to server endpoints.
data-ai
Design and implement Redis data storage for a new feature. Use when adding new data models, leaderboards, counters, or any persistent state.
content-media
Improve interface performance across loading speed, rendering, animations, images, and bundle size. Makes experiences faster and smoother.