AGENT SKILL

replit-policy-guardrails

Implement Replit lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Replit integrations, implementing pre-commit hooks, or configuring CI policy checks for Replit best practices. Trigger with phrases like "replit policy", "replit lint", "replit guardrails", "replit best practices check", "replit eslint".

License 许可
MIT
最近更新
2026-05-26
Stars
★ 0
Forks
0

01 前言 Front Matter

name
replit-policy-guardrails
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Implement Replit lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Replit integrations, implementing pre-commit hooks, or configuring CI policy checks for Replit best practices. Trigger with phrases like "replit policy", "replit lint", "replit guardrails", "replit best practices check", "replit eslint".
allowed-tools
Read, Write, Edit, Bash(npx:*)
compatible-with
claude-code, codex, openclaw

03 SKILL.md 正文

Replit Policy Guardrails

Overview

Policy enforcement for Replit-hosted applications. Replit's shared hosting model, public-by-default Repls, and resource limits require guardrails around secrets exposure, resource consumption, and deployment security.

Prerequisites

  • Replit account with Deployments access
  • Understanding of Replit's security model
  • Awareness of Replit's Terms of Service

Instructions

Step 1: Prevent Secrets Exposure

Replit Repls are public by default. Secrets in code are visible to anyone.

# BAD: secrets in source code (visible in public Repl)
API_KEY = "sk-live-abc123"  # anyone can see this

# GOOD: use Replit Secrets (Environment Variables)
import os
API_KEY = os.environ.get("API_KEY")
if not API_KEY:
    raise RuntimeError("API_KEY not set in Replit Secrets")

# Validate secrets are properly configured on startup
REQUIRED_SECRETS = ["API_KEY", "DATABASE_URL", "JWT_SECRET"]
missing = [s for s in REQUIRED_SECRETS if not os.environ.get(s)]
if missing:
    raise RuntimeError(f"Missing required secrets: {missing}")

Step 2: Resource Usage Limits

Replit enforces CPU and memory limits. Guard against runaway processes.

import resource, signal

# Set memory limit (512MB)
resource.setrlimit(resource.RLIMIT_AS, (512 * 1024 * 1024, 512 * 1024 * 1024))  # 1024: 1 KB

# Set CPU time limit
def timeout_handler(signum, frame):
    raise TimeoutError("Request exceeded CPU time limit")

signal.signal(signal.SIGALRM, timeout_handler)

@app.route('/process')
def process_request():
    signal.alarm(30)  # 30 second max per request
    try:
        result = heavy_computation()
        return jsonify(result)
    except TimeoutError:
        return jsonify({"error": "Request timed out"}), 504  # HTTP 504 Gateway Timeout
    finally:
        signal.alarm(0)  # cancel alarm

Step 3: Deployment Visibility Controls

Ensure production Repls are not accidentally made public.

# Validate deployment configuration before deploy
def validate_deployment_config():
    checks = []
    # Check visibility
    if os.environ.get("REPL_SLUG"):
        # Running on Replit
        if not os.environ.get("REPL_DEPLOYMENT"):
            checks.append("WARNING: Running as Repl, not Deployment (may sleep)")
    # Check required env vars
    if os.environ.get("NODE_ENV") != "production":
        checks.append("WARNING: NODE_ENV not set to production")
    # Check HTTPS
    if not os.environ.get("REPL_DEPLOYMENT"):
        checks.append("INFO: Custom domain HTTPS managed by Replit Deployments")
    return checks

Step 4: Database Access Controls

Replit DB is accessible to anyone with the Repl URL if not properly secured.

from functools import wraps

def require_auth(f):
    @wraps(f)
    def decorated(*args, **kwargs):
        auth = request.headers.get('Authorization')
        if not auth or not verify_token(auth):
            return jsonify({"error": "Unauthorized"}), 401  # HTTP 401 Unauthorized
        return f(*args, **kwargs)
    return decorated

# Protect all database-accessing endpoints
@app.route('/api/data')
@require_auth
def get_data():
    return jsonify(db.get("data"))

Error Handling

Issue Cause Solution
Secrets leaked Code is public by default Use Replit Secrets, never hardcode
OOM kills No memory limits Set resource limits, monitor usage
Unauthorized DB access No auth on endpoints Add authentication middleware
Repl sleeping in prod Using Repl instead of Deployment Use Replit Deployments for production

Examples

Startup Security Check

def security_check():
    issues = []
    if not os.environ.get("JWT_SECRET"):
        issues.append("CRITICAL: JWT_SECRET not configured")
    if os.environ.get("DEBUG") == "true":
        issues.append("WARNING: Debug mode enabled in production")
    return {"secure": len(issues) == 0, "issues": issues}

Resources

Output

  • Configuration files or code changes applied to the project
  • Validation report confirming correct implementation
  • Summary of changes made and their rationale

04 同仓库更多 Skills

SamuelChien
SamuelChien/mega-skills-collection

zustand-store-ts

Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zustand-store-creator

Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zero-trust-config-helper

Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zapier-integration-helper

Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zai-cli

Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

yt-research

Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.

★ 0