一键导入
debugging
Debug common issues in the Shorted project. Use when troubleshooting errors, fixing bugs, or diagnosing problems with the backend, frontend, or database.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Debug common issues in the Shorted project. Use when troubleshooting errors, fixing bugs, or diagnosing problems with the backend, frontend, or database.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Diagnose and fix Shorted web performance (Core Web Vitals, bundle size, Lighthouse/PageSpeed) and keep it from regressing. Use when a PageSpeed/Lighthouse report comes in, LCP/TBT/CLS is high, the JS bundle grows, images are heavy, or someone asks to "make the site faster" / "improve the score".
Operate and improve the Shorted weekly/monthly/yearly short-selling report pipeline — run the generator, iterate on prompts safely, debug quality-gate failures, extend the data snapshot, and keep the generator↔proto JSON contract intact. Use when generating/regenerating reports, tuning report prompts, adding fields to the report snapshot, or debugging /reports pages.
Operate and improve the Shorted investigative newsroom — generate, validate, publish, and iterate on MDX editorial takes. Use when running newsroom-daily/preview, regenerating images, fixing article quality, extending the MDX component palette, or debugging duplicates in the wire feed.
Compose and post full-stack social posts to @shorted___ on X — text + X-card link preview + generated infographic. Wraps the Twitter bot, /api/og/twitter PNG endpoint, and /news/[slug] editorial pages. Use when the user says "post a tweet", "tweet today's shorts", "share to X", "social post", "compose a tweet about $TICKER", or "/social-post".
Add new Connect-RPC API endpoints to the shorts backend. Use when creating new API methods, defining protobuf services, or implementing backend handlers.
Manage data population and synchronization for ASIC short data and stock prices. Use when populating the database, syncing data, or troubleshooting data issues.
| name | debugging |
| description | Debug common issues in the Shorted project. Use when troubleshooting errors, fixing bugs, or diagnosing problems with the backend, frontend, or database. |
| allowed-tools | Read, Bash(make:*), Bash(docker:*), Bash(lsof:*), Bash(curl:*), Bash(psql:*), Grep, Glob |
This skill helps you diagnose and fix common issues in the Shorted project.
# Check if services are running
make dev-db && docker ps
# Check ports in use
lsof -i :3020 # Frontend
lsof -i :9091 # Backend
lsof -i :5438 # Database
# Kill stale processes
make clean-ports
# Full restart
make dev-stop && make dev
Symptom: make dev-backend fails or hangs
Steps:
Check for port conflicts:
lsof -i :9091
Kill stale processes:
make clean-ports
Check database is running:
docker ps | grep shorted_db
Test database connection:
psql postgresql://admin:password@localhost:5438/shorts -c "SELECT 1"
Check for Go compilation errors:
cd services && go build ./shorts/cmd/server/...
Check environment variables:
echo $DATABASE_URL
# Should be: postgresql://admin:password@localhost:5438/shorts
Symptom: make dev-frontend fails
Steps:
Clear Next.js cache:
make clean-cache
Reinstall dependencies:
cd web && rm -rf node_modules && npm install
Check for TypeScript errors:
cd web && npx tsc --noEmit
Check port availability:
lsof -i :3020
Symptom: "connection refused" or timeout errors
Steps:
Start the database:
make dev-db
Check container status:
docker ps
docker logs shorted_db
Wait for database to be ready:
until docker exec shorted_db pg_isready -U admin -d shorts; do
sleep 2
done
Test connection:
psql postgresql://admin:password@localhost:5438/shorts -c "\dt"
If container won't start, reset:
cd analysis/sql && docker compose down -v
cd analysis/sql && docker compose up -d postgres
Symptom: Backend returns internal server errors
Steps:
Check backend logs (run in foreground):
cd services && DATABASE_URL=postgresql://admin:password@localhost:5438/shorts \
go run shorts/cmd/server/main.go
Test specific endpoint:
curl -v -X POST http://localhost:9091/v1/topShorts \
-H "Content-Type: application/json" \
-d '{"period": "1m", "limit": 10}'
Check database has data:
psql postgresql://admin:password@localhost:5438/shorts \
-c "SELECT COUNT(*) FROM shorts"
Verify database schema:
cd services && make migrate-version
cd services && make migrate-up
Symptom: UI shows empty state or loading forever
Steps:
Check backend is responding:
curl http://localhost:9091/health
Test API directly:
curl -X POST http://localhost:9091/v1/topShorts \
-H "Content-Type: application/json" \
-d '{"period": "1m", "limit": 10}' | jq
Check browser console for errors (open DevTools)
Check network tab for failed requests
Verify environment variables in .env.local:
cat web/.env.local
# Should have NEXT_PUBLIC_API_URL or similar
Symptom: make test-integration-local fails
Steps:
Ensure Docker is running:
docker info
Clean up old containers:
docker system prune -f
Run with verbose output:
cd services && go test -v ./test/integration/... -timeout=20m
Check testcontainer logs in test output
Symptom: API responses take >1 second
Steps:
Diagnose slow queries:
make db-diagnose
Apply performance indexes:
make db-optimize
Update statistics:
psql postgresql://admin:password@localhost:5438/shorts \
-c "ANALYZE shorts; ANALYZE \"company-metadata\"; ANALYZE stock_prices;"
Check query plan:
EXPLAIN ANALYZE
SELECT * FROM shorts
WHERE "PRODUCT_CODE" = 'BHP'
ORDER BY "DATE" DESC
LIMIT 100;
Symptom: make test fails on linting
Steps:
Run linting separately:
make lint-frontend
make lint-backend
Auto-fix TypeScript issues:
cd web && npm run lint -- --fix
Auto-fix Go issues:
cd services && make lint-fix
Format code:
make format
cd services && LOG_LEVEL=debug \
DATABASE_URL=postgresql://admin:password@localhost:5438/shorts \
go run shorts/cmd/server/main.go
Add to web/.env.local:
DEBUG=*
-- Enable query logging (temporary)
SET log_statement = 'all';
SET log_duration = on;
# Backend health
curl http://localhost:9091/health
# Database health
docker exec shorted_db pg_isready -U admin -d shorts
# Full system check
make health-check
| Service | How to View |
|---|---|
| Backend | Terminal output (foreground) or docker logs |
| Frontend | Terminal output + browser DevTools |
| Database | docker logs shorted_db |
| Cloud Run | make daily-sync-logs |
# See all running containers
docker ps
# See all processes on common ports
lsof -i :3020,9091,5438,8090
# Database shell
psql postgresql://admin:password@localhost:5438/shorts
# Watch backend logs
cd services && make run.shorts 2>&1 | tee backend.log
# Generate fresh mocks (if tests fail on mock errors)
cd services && go generate ./...