一键导入
retro-cross-cutting
Extracts error handling patterns, security mechanisms, logging, configuration, and non-functional requirements from legacy code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Extracts error handling patterns, security mechanisms, logging, configuration, and non-functional requirements from legacy code
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Test failure diagnosis, source code fixes, and regression detection
Environment verification, dependency installation, baseline test verification
Contract-first single-task implementation dispatched by Coder Coordinator
Integration test writing for component boundaries and external dependencies
Unit test writing and execution with coverage threshold enforcement
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
| name | retro-cross-cutting |
| description | Extracts error handling patterns, security mechanisms, logging, configuration, and non-functional requirements from legacy code |
| argument-hint | Invoked by Retro-Spec Coordinator - do not call directly |
This skill is invoked by the Retro-Spec Coordinator as the fifth extraction skill. It analyzes cross-cutting concerns in the legacy codebase: error handling, security, logging, configuration management, and non-functional characteristics. It produces Sections 10 (Non-Functional Requirements), 12 (Constraints & Assumptions), and 13 (Out of Scope), plus the error-catalog artifact.
| # | Input | Description |
|---|---|---|
| 1 | skill_path | Path to this SKILL.md file |
| 2 | accumulator_path | Path to the spec file being built |
| 3 | artifacts_dir | Path to companion artifacts directory |
| 4 | discovery_manifest_path | Path to the discovery manifest |
| 5 | source_path | Path to the legacy source code |
| 6 | target_language | Target language for artifacts |
| 7 | project_name | Name of the project |
| 8 | module_filter | Modules to analyze |
#tool:search/usages to trace error handlers, auth middleware, and logging symbols across the codebase.error-catalog.<ext> in the artifacts directory[INFERRED: confidence] for every NFRGlobal error handlers: Search for centralized error handling:
grep: "errorHandler|error.middleware|exception_handler|@ExceptionHandler|recover|catch|rescue"
Error class definitions: Search for custom error types:
grep: "extends Error|extends Exception|class.*Error|class.*Exception|errors.New|#\[derive.*Error\]"
Error response patterns: Analyze how errors are translated to responses:
Error propagation: How errors flow through the system:
Build error catalog:
| Error Code | HTTP Status | Message Template | Thrown By | Source |
|---|---|---|---|---|
| VALIDATION_ERROR | 400 | "Invalid input: {details}" | Validators | file:line |
| NOT_FOUND | 404 | "{entity} not found" | Repositories | file:line |
Analyze security mechanisms WITHOUT executing any code:
Authentication:
bcrypt, argon2, scrypt, pbkdf2)grep: "jwt|jsonwebtoken|passport|bcrypt|argon2|session|cookie|bearer|apiKey|auth"
Authorization:
Input sanitization:
Transport security:
Secrets management:
.gitignore patterns for sensitive filesKnown vulnerabilities:
Logging framework: Identify which logger is used:
grep: "winston|pino|bunyan|log4j|logback|logging|slog|tracing|log\.Info|logger\."
Log levels used: Which levels (debug, info, warn, error) are used where
Structured logging: Are logs structured (JSON) or unstructured (text)?
Request logging: Is there HTTP request/response logging middleware?
Health checks: Health check endpoints (/health, /healthz, /ready, /live)
Metrics: Prometheus, StatsD, CloudWatch, or other metrics collection
Tracing: Distributed tracing (OpenTelemetry, Jaeger, Zipkin)
Config sources: Where configuration comes from:
Config schema: What config values exist and their types:
.env.example, config.ts, settings.py, etc.Environment-specific: Different configs per environment (dev, staging, prod)
Feature flags: Any feature toggle mechanism
Analyze code for performance-related patterns:
## 10. Non-Functional Requirements
### 10.1 Performance
- **NFR-P01**: The system SHALL respond to API requests within <X>ms at the 95th percentile.
[INFERRED: LOW] -- No explicit SLA found in code; inferred from timeout configurations.
Source: <timeout config file:line>
- **NFR-P02**: The system SHALL support pagination with configurable page size (default: <N>, max: <M>).
[INFERRED: HIGH] Source: <pagination implementation:line>
### 10.2 Security
- **NFR-S01**: The system SHALL authenticate users via <mechanism>.
[INFERRED: HIGH] Source: <auth middleware:line>
- **NFR-S02**: The system SHALL hash passwords using <algorithm> with <rounds> rounds.
[INFERRED: HIGH] Source: <password hashing:line>
- **NFR-S03**: The system SHALL enforce CORS with allowed origins: <origins>.
[INFERRED: HIGH] Source: <CORS config:line>
#### OWASP Mapping
| OWASP Category | Current Implementation | Gap | Source |
|---------------|----------------------|-----|--------|
| A01 Broken Access Control | Role-based middleware on all endpoints | No ABAC | <file:line> |
| A02 Cryptographic Failures | bcrypt for passwords, HTTPS enforced | No data-at-rest encryption | <file:line> |
| A03 Injection | Parameterized queries via ORM | No input sanitization on <field> | <file:line> |
### 10.3 Scalability
- **NFR-SC01**: The system SHALL <scalability characteristic>.
[INFERRED: confidence] Source: <evidence>
### 10.4 Observability
- **NFR-O01**: The system SHALL log all requests with <log fields>.
[INFERRED: HIGH] Source: <logging middleware:line>
- **NFR-O02**: The system SHALL expose a health check endpoint at <path>.
[INFERRED: HIGH] Source: <health route:line>
### 10.5 Configuration
| Config Key | Type | Required | Default | Purpose | Source |
|-----------|------|----------|---------|---------|--------|
| DATABASE_URL | string | yes | - | Database connection | <env file:line> |
| PORT | integer | no | 3000 | Server port | <config file:line> |
## 12. Constraints & Assumptions
### 12.1 Technical Constraints
| # | Constraint | Evidence | Source |
|---|-----------|----------|--------|
| TC-01 | Requires Node.js >= 18 | engines field in package.json | <file:line> |
| TC-02 | PostgreSQL 14+ required | Migration syntax | <file:line> |
### 12.2 Assumptions
| # | Assumption | Confidence | Basis |
|---|-----------|------------|-------|
| A-01 | Single-tenant deployment | [INFERRED: MEDIUM] | No tenant isolation code found |
| A-02 | UTC timezone for all timestamps | [INFERRED: HIGH] | All dates use UTC methods |
## 13. Out of Scope
Items detected in the codebase that appear incomplete, experimental, or disabled:
| # | Item | Evidence | Recommendation |
|---|------|----------|----------------|
| OOS-01 | <feature behind flag> | Feature flag disabled | Include in future phase |
| OOS-02 | <commented-out code> | Commented since <git blame> | Evaluate relevance |
// Generated by: retro-cross-cutting skill (retro-spec)
// Source legacy code: <source_path>
// Target language: TypeScript
// Confidence: HIGH
// DO NOT EDIT MANUALLY -- regenerated on retro-spec re-run
export const ErrorCodes = {
// --- Client Errors (4xx) ---
VALIDATION_ERROR: { status: 400, message: "Invalid input" },
UNAUTHORIZED: { status: 401, message: "Authentication required" },
FORBIDDEN: { status: 403, message: "Insufficient permissions" },
NOT_FOUND: { status: 404, message: "Resource not found" },
CONFLICT: { status: 409, message: "Resource conflict" },
// --- Server Errors (5xx) ---
INTERNAL_ERROR: { status: 500, message: "Internal server error" },
} as const;
export type ErrorCode = keyof typeof ErrorCodes;
export interface ErrorResponse {
error: ErrorCode;
message: string;
details?: Record<string, string[]>;
}