pseudocode-to-python-code — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited pseudocode-to-python-code (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Convert pseudocode and algorithm descriptions into complete, executable Python code with proper structure, documentation, and tests.
Identify the input format and extract the algorithm logic:
Natural language description:
Structured pseudocode:
Algorithm specification:
Mixed format:
Break down the algorithm into components:
Use references/pseudocode-patterns.md for common mappings:
Control structures:
if/elif/elsefor i in range() or for item in collectionwhile condition:while True: with breakData structures:
listdictsetlist with append()/pop()collections.dequeheapqCommon operations:
a, b = b, amin(), max()sorted() or list.sort()in operator, list.index(), or binary searchFollow this structure using assets/template.py as a base:
Module header:
#!/usr/bin/env python3
"""
Brief description of what this module does.
Implements [algorithm name] with [key features].
"""
from typing import List, Dict, Optional, Tuple, Set, AnyMain function:
def algorithm_name(param1: type1, param2: type2) -> return_type:
"""Brief description.
Detailed explanation of the algorithm, including approach and complexity.
Args:
param1: Description with constraints
param2: Description with constraints
Returns:
Description of return value
Raises:
ValueError: When input is invalid
TypeError: When input type is wrong
Examples:
>>> algorithm_name([3, 1, 2])
[1, 2, 3]
"""
# Input validation
if not param1:
raise ValueError("param1 cannot be empty")
# Main algorithm implementation
# Use clear variable names and comments for complex logic
result = implementation_here
return resultHelper functions:
Test cases:
def test_algorithm_name():
"""Test algorithm_name with various inputs."""
# Test 1: Normal case
assert algorithm_name([3, 1, 2]) == [1, 2, 3]
# Test 2: Edge case - empty
try:
algorithm_name([])
assert False, "Should raise ValueError"
except ValueError:
pass
# Test 3: Edge case - single element
assert algorithm_name([1]) == [1]
# Test 4: Edge case - duplicates
assert algorithm_name([2, 1, 2]) == [1, 2, 2]
# Test 5: Edge case - already sorted
assert algorithm_name([1, 2, 3]) == [1, 2, 3]
print("✓ All tests passed!")Main block:
if __name__ == "__main__":
# Run tests
test_algorithm_name()
# Example usage
example_input = [3, 1, 4, 1, 5, 9, 2, 6]
result = algorithm_name(example_input)
print(f"Input: {example_input}")
print(f"Output: {result}")Consult references/python-idioms.md for best practices:
Use list comprehensions:
# Instead of loops
result = [transform(x) for x in items if condition(x)]Use built-in functions:
# Instead of manual loops
total = sum(items)
maximum = max(items)Use enumerate and zip:
for i, item in enumerate(items):
process(i, item)
for a, b in zip(list1, list2):
process(a, b)Use appropriate data structures:
collections.defaultdict for counting/groupingcollections.Counter for frequency countingcollections.deque for queuesheapq for priority queuesInclude appropriate error handling:
def function(param):
"""Function with error handling."""
# Validate input
if param is None:
raise ValueError("param cannot be None")
if not isinstance(param, expected_type):
raise TypeError(f"Expected {expected_type}, got {type(param)}")
# Check constraints
if param < 0:
raise ValueError("param must be non-negative")
# Implementation
try:
result = risky_operation(param)
except SpecificError as e:
# Handle or re-raise with context
raise RuntimeError(f"Operation failed: {e}") from e
return resultGenerate test cases covering:
After generating code, provide a summary:
Pseudocode to Python Mapping Summary:
======================================
Algorithm: [Name]
Complexity: Time O(...), Space O(...)
Key Mappings:
1. FOR i FROM 1 TO n → for i in range(1, n + 1)
2. ARRAY[n] → list of size n
3. IF condition THEN → if condition:
4. SWAP(a, b) → a, b = b, a
Data Structures Used:
- Input: List[int]
- Auxiliary: Dict[str, int] for tracking
Functions Generated:
- main_function(): Main algorithm implementation
- helper_function(): Helper for [specific task]
Test Cases: 5 tests covering normal and edge casesUser provides clear pseudocode:
FOR i FROM 0 TO n-1
FOR j FROM 0 TO n-i-1
IF array[j] > array[j+1]
SWAP array[j] and array[j+1]for, SWAP → tuple unpackingUser describes algorithm in English: "Create a function that finds the longest common subsequence of two strings"
User provides formal specification: "Precondition: Binary tree is not empty. Find the lowest common ancestor of two nodes."
User describes object-oriented algorithm: "Implement a stack with min() operation in O(1)"
__init__, push, pop, min, is_emptyExtract helper functions when:
if __name__ == "__main__" block~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.