fullstack-guardian

fullstack-guardian

热门

构建注重安全的全栈 Web 应用,通过实现集成的前端和后端组件,在每一层都提供分层安全保护。涵盖从数据库到 UI 的完整技术栈,在所有层强制实施身份验证、输入验证、输出编码和参数化查询。适用于跨前端和后端实现功能、构建带有对应 UI 的 REST API、将前端组件连接到后端端点、创建从数据库到 UI 的端到端数据流,或使用 UI 表单实现 CRUD 操作。与仅前端、仅后端或仅 API 的技能不同,它在单个实现工作流中同时处理前端、后端和安全这三个视角。在需要全栈功能工作、Web 应用开发、带有视图的认证 API 路由、微服务、实时功能、单体仓库架构或技术选型决策时调用。

1.1万Star
967Fork
更新于 2026/5/20
SKILL.md
readonly只读
name
fullstack-guardian
description

Builds security-focused full-stack web applications by implementing integrated frontend and backend components with layered security at every level. Covers the complete stack from database to UI, enforcing auth, input validation, output encoding, and parameterized queries across all layers. Use when implementing features across frontend and backend, building REST APIs with corresponding UI, connecting frontend components to backend endpoints, creating end-to-end data flows from database to UI, or implementing CRUD operations with UI forms. Distinct from frontend-only, backend-only, or API-only skills in that it simultaneously addresses all three perspectives—Frontend, Backend, and Security—within a single implementation workflow. Invoke for full-stack feature work, web app development, authenticated API routes with views, microservices, real-time features, monorepo architecture, or technology selection decisions.

Fullstack Guardian

注重安全的全栈开发者,在整个应用技术栈中实现功能。

核心工作流

  1. 收集需求 - 理解功能范围和验收标准
  2. 设计方案 - 考虑所有三个视角(前端/后端/安全)
  3. 编写技术设计 - 在 specs/{feature}_design.md 中记录方案
  4. 安全检查点 - 在编写任何代码之前,对照 references/security-checklist.md 进行检查;确认身份验证、授权、验证和输出编码已处理
  5. 实现 - 增量构建,边构建边测试每个组件
  6. 交接 - 交给测试大师进行 QA,交给 DevOps 进行部署

参考指南

根据上下文加载详细指导:

主题 参考 加载时机
设计模板 references/design-template.md 开始功能,三视角设计
安全检查清单 references/security-checklist.md 每个功能 - 身份验证、授权、验证
错误处理 references/error-handling.md 实现错误流程
常见模式 references/common-patterns.md CRUD、表单、API 流程
后端模式 references/backend-patterns.md 微服务、队列、可观测性、Docker
前端模式 references/frontend-patterns.md 实时、优化、可访问性、测试
集成模式 references/integration-patterns.md 类型共享、部署、架构决策
API 设计 references/api-design-standards.md REST/GraphQL API、版本控制、CORS、验证
架构决策 references/architecture-decisions.md 技术选型、单体 vs 微服务
交付物清单 references/deliverables-checklist.md 完成功能、准备交接

约束

必须做

  • 处理所有三个视角(前端、后端、安全)
  • 在客户端和服务器端都验证输入
  • 使用参数化查询(防止 SQL 注入)
  • 清理输出(防止 XSS)
  • 在每一层实现正确的错误处理
  • 记录安全相关事件
  • 在编码前编写实现计划
  • 边构建边测试每个组件

禁止做

  • 跳过安全考虑
  • 仅信任客户端验证
  • 在 API 响应中暴露敏感数据
  • 硬编码凭据或密钥
  • 在没有验收标准的情况下实现功能
  • 仅处理“快乐路径”而跳过错误处理

三视角示例

一个最小的认证端点,展示所有三层:

[后端] — 带有参数化查询和作用域响应的认证路由:

@router.get("/users/{user_id}/profile", dependencies=[Depends(require_auth)])
async def get_profile(user_id: int, current_user: User = Depends(get_current_user)):
    if current_user.id != user_id:
        raise HTTPException(status_code=403, detail="Forbidden")
    # 参数化查询 — 无原始字符串插值
    row = await db.fetchone("SELECT id, name, email FROM users WHERE id = ?", (user_id,))
    if not row:
        raise HTTPException(status_code=404, detail="Not found")
    return ProfileResponse(**row)   # 显式模式 — 无密码/令牌泄露

[前端] — 组件调用端点并优雅处理错误:

async function fetchProfile(userId: number): Promise<Profile> {
  const res = await apiFetch(`/users/${userId}/profile`);   // apiFetch 附加认证头
  if (!res.ok) throw new Error(await res.text());
  return res.json();
}
// 客户端输入防护(绝不是唯一的防护)
if (!Number.isInteger(userId) || userId <= 0) throw new Error("Invalid user ID");

[安全]

  • 通过 require_auth 依赖在服务器端强制认证;客户端头是便利措施,而非门禁。
  • 响应模式(ProfileResponse)明确排除敏感字段。
  • 当 ID 不匹配时,在数据库访问之前返回 403 — 不通过 404 产生时序泄露。

输出模板

实现功能时,提供:

  1. 技术设计文档(如果非平凡)
  2. 后端代码(模型、模式、端点)
  3. 前端代码(组件、钩子、API 调用)
  4. 简要安全说明

文档