.stencila/skills/software-code-review/SKILL.md
Evaluate source code for correctness, quality, security, style conformance, and maintainability, producing a structured review report with findings and recommendations. Use when the user wants to review, critique, audit, evaluate, or inspect source code — checking for bugs, logic errors, unhandled error paths, security vulnerabilities, naming and readability issues, complexity, duplication, coupling, testability, and API design. Discovers codebase conventions independently and produces an actionable report with severity-graded findings grouped by category, prioritized recommendations, and open questions.
npx skillsauth add stencila/stencila software-code-reviewInstall 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.
Review source code for correctness, quality, security, style conformance, and maintainability. This skill reads and evaluates code — it does not modify any files. The output is a structured review report with an overall assessment, strengths, severity-graded findings grouped by category, prioritized recommendations, and open questions.
Do not use this skill when the main task is to write code, refactor code, create tests, review tests, review a design, or review a delivery plan.
| Input | Required | Description | |---------------------|----------|----------------------------------------------------------------------| | Target files | Yes | Paths to the source code files to review | | Review focus | No | Specific areas to prioritize (e.g., "security", "error handling", "API design") | | Target packages | No | Packages, crates, modules, or directories involved | | Acceptance criteria | No | Requirements or criteria the code should satisfy |
When used standalone, these inputs come from the user or the agent's prompt. When used within a workflow, the workflow's stage prompt will specify how to obtain them.
| Output | Description | |-----------------|-------------------------------------------------------------------------------| | Overall verdict | Summary assessment of the code's quality and readiness | | Review report | Structured report with strengths, findings, recommendations, and open questions |
Ensure the required inputs are available:
read_file to load each target fileIndependently discover the codebase's conventions to evaluate style conformance. Do not assume conventions from the target files themselves — those files may deviate from the codebase's norms.
glob to search for build and configuration files in the relevant packages:
**/Cargo.toml, **/go.mod, **/package.json, **/tsconfig.json, **/pyproject.toml, **/setup.py, **/Gemfile, **/Makefile, **/CMakeLists.txtglob and grep to find source files in the target packagesread_file to examine 2–3 representative source files (other than the target files) to learn:
Analyze the code for bugs, logic errors, and unhandled error paths:
unwrap() in Rust, unchecked exceptions)Analyze the code for security vulnerabilities and unsafe patterns:
Flag security findings with appropriate severity — a hardcoded secret or SQL injection is High; a missing input length check may be Medium or Low depending on context.
Assess code quality and adherence to codebase conventions:
Assess the code's long-term maintainability:
If acceptance criteria were provided:
| Acceptance Criterion | Status | Notes | |---|---|---| | Criterion text | ✅ Satisfied / ❌ Not satisfied / ⚠️ Partially satisfied | Brief explanation |
Follow the Report Format below.
One to three sentences summarizing the code's quality and the most important findings. State the overall quality level and the primary area needing attention.
A short bullet list of what the code does well. Recognizing strengths helps the author know what to preserve.
Include this section only if acceptance criteria were provided. Use the coverage matrix from Step 8.
Group findings under these headings when relevant (omit headings with no findings):
For each finding:
Severity guidelines:
A numbered list of concrete improvements in priority order. Each recommendation should say what to change, where, and why. When useful, suggest specific approaches, patterns, or restructuring strategies.
List questions that should be answered to improve confidence in the review. Include this section only when such questions remain — for example, when the reviewer cannot determine whether a pattern is intentional without more context, or when the review focus was too narrow to fully assess a concern.
Target files: src/auth/token.rs
Review:
Overall Assessment
The token validation function has a critical logic error that accepts expired tokens and a hardcoded fallback secret. These must be fixed before the code is safe for production.
Strengths
- Clear function signature with appropriate error types
- Good use of the codebase's
AuthErrorenum for error reporting- Follows the module's existing import and naming conventions
Findings
Correctness
- High:
validate_tokeninsrc/auth/token.rs:42-58comparestoken.exp > nowbut should comparetoken.exp < nowto detect expiration. Currently, all expired tokens are accepted and all valid tokens are rejected.Security
- High:
src/auth/token.rs:15contains a hardcoded fallback secret"dev-secret-key"used when the environment variable is not set. This would allow token forgery in any deployment that fails to set the variable.- Medium:
src/auth/token.rs:51logs the full token payload atdebuglevel, which could expose user claims in log files.Quality and style
- Low: The function
validate_tokenis 40 lines long. Extracting the claims-parsing logic into a helper would improve readability, consistent with howparse_headeris structured in the same module.Recommendations
- Fix the expiration check on line 45: change
token.exp > nowtotoken.exp < now- Remove the hardcoded fallback secret on line 15. Return an error when the environment variable is missing instead of falling back to an insecure default.
- Redact or remove the debug log of the full token payload on line 51. Log only the token ID or a truncated hash if debugging information is needed.
- Consider extracting the claims-parsing block (lines 30–45) into a
parse_claimshelper for consistency with the module's existing structure.
Target files: lib/handlers/user_handler.py, lib/handlers/order_handler.py
Review focus: maintainability
Review:
Overall Assessment
Both handler files work correctly but share significant duplicated code and are tightly coupled to the database module through direct imports of internal functions. Refactoring the shared patterns into a base handler and using the public
db.queryAPI would substantially improve maintainability.Strengths
- Both handlers follow the project's URL routing convention
- Error responses use the standardized
ErrorResponseformat consistently- Input validation is present for all endpoints
Findings
Quality and style
- Medium:
user_handler.py:12-35andorder_handler.py:15-38contain nearly identical authentication and permission-checking boilerplate. This pattern is repeated in both files and would need to be updated in multiple places if the auth logic changes.- Low:
order_handler.py:72usescamelCasefor the local variableorderItems, while the rest of the codebase usessnake_case. The codebase convention (confirmed inlib/handlers/product_handler.pyandlib/utils/helpers.py) issnake_casethroughout.Maintainability
- Medium: Both handlers import
db._execute_raw_query(a private function indicated by the underscore prefix) instead of using the publicdb.queryinterface. This creates tight coupling to the database module's internals and would break if the internal implementation changes.- Medium:
user_handler.py:88-120contains a 32-line functionhandle_updatethat mixes validation, database access, cache invalidation, and response formatting. Separating these concerns would make each step independently testable.- Low: Neither handler has type annotations on function parameters or return values, while the three other handler files in
lib/handlers/all use type annotations. Adding them would improve IDE support and catch type errors earlier.Recommendations
- Extract the shared auth/permission boilerplate into a decorator or base handler class to eliminate duplication and centralize auth logic changes
- Replace
db._execute_raw_queryimports withdb.queryin both handlers to depend on the public API- Break
handle_updateinto smaller functions:validate_update_request,apply_update,invalidate_user_cache, to improve testability- Rename
orderItemstoorder_itemson line 72 oforder_handler.pyto match the codebase'ssnake_caseconvention- Add type annotations to function signatures in both handlers for consistency with the rest of
lib/handlers/
documentation
An agent skill providing instructions for AI agents.
testing
Critically review a Stencila workflow and suggest improvements. Use when asked to review, audit, critique, evaluate, or improve a workflow directory or WORKFLOW.md file. Covers frontmatter validation, DOT pipeline quality, workflow structure, agent selection quality, discovery metadata, ephemeral workflow conventions, workflow composition, and adherence to Stencila workflow patterns.
development
Create a new Stencila workflow. Use when asked to create, write, scaffold, or set up a workflow directory or WORKFLOW.md file. Covers workflow discovery, duplicate-name checks, ephemeral workflows, WORKFLOW.md frontmatter, DOT pipeline authoring, goals, agents, branching, composition, and validation.
development
Critically review an existing or proposed Stencila theme artifact for correctness, token usage, target coverage, cross-target portability, dark-mode handling, maintainability, and approval readiness. Use when asked to review, critique, assess, audit, or validate a theme.css file, theme patch, theme plan, site theme, document theme, plot theme, print or PDF theme, check design tokens, assess DOCX or email behavior, review dark mode support, or validate with stencila themes validate.