Secure & Maintainable Code Generation

VerifiedSafe

Generates production-quality code following clean code principles, security best practices (no hardcoded secrets, input validation), explicit error handling, and type hints. Provides structured templates (dataclasses, documented functions) and language-specific guidelines (Python, JavaScript, Go). Helps developers write maintainable and secure code from the start.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#code#programming#security#testing#best-practices

Recommended for

Automated summary

This skill generates production-quality code following best practices for cleanliness, security, maintainability, and testing.

Strengths

  • Covers multiple languages (Python, JavaScript/TypeScript, Go) with specific guidelines.
  • Includes a detailed security checklist and secure code examples.
  • Provides unit test templates and coverage advice.
  • Offers clear project structure and design principles like DRY and single responsibility.

Limitations

  • Examples are generic and may need adaptation to the project context.
  • Does not cover all popular languages or frameworks.
  • Depth of advice may be limited for highly specific cases.
When to use it

Use this skill when you need to quickly generate reliable, secure, and maintainable code for standard modules or APIs.

When not to use it

Avoid using it for highly specialized algorithms or domains requiring deep expertise beyond common patterns.

Security analysis

Safe
Quality score90/100

The skill contains only educational best practices and code examples; no executable commands or dangerous instructions.

No concerns found

How this analysis is made

Examples

Python API fetch with error handling
Generate a Python function to fetch data from an API with proper error handling, type hints, and use environment variables for the API key.
Node.js secure SQL query
Write a Node.js function that executes a SQL query using parameterized inputs to prevent SQL injection.
Go web server with logging
Create a Go HTTP server with a /health endpoint, request logging, and proper error handling using channel-based communication.

name: code-generation description: Best practices and patterns for generating clean, secure, maintainable code version: 1.0.0 author: Multi-Agent System category: development tags: [code, programming, security, testing, best-practices] prerequisites: [programming-basics] capabilities: [code-structure, security-patterns, error-handling, testing-strategies] output_format: code_with_documentation

Code Generation Skill

You are an expert in generating production-quality code that is clean, secure, maintainable, and well-tested.

Code Quality Principles

1. Clean Code

  • Meaningful names: Variables, functions, classes describe their purpose
  • Single responsibility: Each function does one thing well
  • DRY principle: Don't repeat yourself - extract common patterns
  • Comments: Explain "why", not "what" - code should be self-documenting

2. Security First

# ❌ BAD - Hardcoded credentials
password = "admin123"

# ✅ GOOD - Environment variables
password = os.getenv("DB_PASSWORD")
if not password:
    raise ValueError("DB_PASSWORD not set")

3. Error Handling

# Specific exceptions, not bare except
try:
    result = risky_operation()
except ValueError as e:
    logger.error(f"Invalid input: {e}")
    raise
except Exception as e:
    logger.exception(f"Unexpected error: {e}")
    raise

4. Type Hints

from typing import List, Optional

def process_items(
    items: List[str],
    threshold: Optional[int] = None
) -> dict[str, int]:
    """Process items and return statistics."""
    # Implementation...

Language-Specific Guidelines

Python

  • Follow PEP 8 style guide
  • Use type hints (Python 3.9+)
  • Prefer dataclasses over classes for data containers
  • Use context managers for resource management
  • Avoid mutable default arguments

JavaScript/TypeScript

  • Use const and let, never var
  • Prefer arrow functions for callbacks
  • Use template literals for string interpolation
  • Async/await over promise chains
  • JSDoc for function documentation

Go

  • Error handling: never ignore errors
  • Use goroutines sparingly
  • Prefer interfaces over concrete types
  • Keep goroutines lightweight
  • Use channels for communication

Code Structure

File Organization

src/
├── __init__.py
├── models.py          # Data models
├── services.py         # Business logic
├── repositories.py     # Data access
├── schemas.py          # Validation schemas
├── utils.py            # Utilities
└── config.py           # Configuration

Function Template

def function_name(
    param1: type,
    param2: type,
    optional_param: type = default_value,
) -> return_type:
    """Brief description of function.

    Args:
        param1: Description of param1
        param2: Description of param2
        optional_param: Description of optional param

    Returns:
        Description of return value

    Raises:
        SpecificException: When condition occurs

    Example:
        >>> result = function_name("test", 42)
        >>> print(result)
        'output'
    """
    # Implementation
    pass

Security Checklist

  • [ ] No hardcoded credentials
  • [ ] Input validation on all user inputs
  • [ ] Parameterized queries for database
  • [ ] Output encoding to prevent XSS
  • [ ] Proper error handling (no info leakage)
  • [ ] Principle of least privilege for permissions
  • [ ] Secrets in environment variables
  • [ ] Dependency security scanning

Testing Guidelines

Unit Tests

def test_function_success_case():
    """Test the happy path."""
    result = function_name("valid_input", 10)
    assert result.status == "success"

def test_function_edge_case():
    """Test edge conditions."""
    result = function_name("", 0)
    assert result.status == "invalid"

def test_function_error_handling():
    """Test error cases."""
    with pytest.raises(ValueError):
        function_name("invalid", -1)

Test Coverage

  • Aim for 80%+ coverage on critical paths
  • Test success cases, edge cases, and error cases
  • Mock external dependencies
  • Use fixtures for common test data

Performance Considerations

  1. Algorithm choice: Use appropriate data structures
  2. Caching: Cache expensive operations
  3. Lazy loading: Load resources only when needed
  4. Batching: Group operations to reduce overhead
  5. Profiling: Measure before optimizing

When to Use This Skill

Use code-generation when:

  • Writing implementation code
  • Refactoring existing code
  • Adding new features
  • Creating API endpoints
  • Building data pipelines

Output Format

Generate code with:

  1. File path as comment header
  2. Imports organized (stdlib, third-party, local)
  3. Type hints throughout
  4. Docstrings for functions/classes
  5. Example usage in comments
  6. Error handling
  7. Logging where appropriate
  8. Test examples

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/secure-maintainable-code-generation-mmh8qq9v/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/secure-maintainable-code-generation-mmh8qq9v' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/secure-maintainable-code-generation-mmh8qq9v/download' --output '.skill-downloads/secure-maintainable-code-generation-mmh8qq9v/SKILL.md.part' && mv '.skill-downloads/secure-maintainable-code-generation-mmh8qq9v/SKILL.md.part' '.skill-downloads/secure-maintainable-code-generation-mmh8qq9v/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/secure-maintainable-code-generation-mmh8qq9v/SKILL.md' && test -s '.skill-downloads/secure-maintainable-code-generation-mmh8qq9v/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/code-generation' && cp -R '.skill-downloads/secure-maintainable-code-generation-mmh8qq9v' '.claude/skills/code-generation'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/secure-maintainable-code-generation-mmh8qq9v'

openskills read 'secure-maintainable-code-generation-mmh8qq9v'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/secure-maintainable-code-generation-mmh8qq9v/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills