code-generation

Code Generation Skill

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "code-generation" with this command: npx skills add azeem-2/final-docusarus/azeem-2-final-docusarus-code-generation

Code Generation Skill

This skill defines the standards for generating code examples in educational content. The goal is to produce code that is not just functional, but exemplary—teaching best practices by example.

Core Philosophy

  • Readability First: Code is read more often than written. Optimize for the reader.

  • Pedagogical Clarity: Avoid "clever" one-liners. Prefer explicit, step-by-step logic.

  • Standard Compliance: Strictly follow language-specific style guides (e.g., PEP 8 for Python).

  • Self-Documenting: Variable names should explain their purpose. Comments should explain why, not what.

General Standards

  1. Naming Conventions
  • Descriptive Names: Use user_age instead of a , total_price instead of tp .

  • No Single Letters: Exception for loop counters (i , j ) in generic contexts, but prefer for item in items .

  • Consistency: Stick to the language's standard (snake_case for Python, camelCase for JS).

  1. Comments and Documentation
  • Explain the 'Why':

  • ❌ x = x + 1 # Increment x

  • ✅ retry_count += 1 # Track attempts to prevent infinite loop

  • Docstrings: All functions and classes must have a docstring explaining inputs, outputs, and purpose.

  • Inline Comments: Use sparingly for complex logic.

  1. Error Handling
  • No Silent Failures: Never use bare try...except (Python) or empty catch blocks.

  • Explicit Exceptions: Catch specific errors (e.g., ValueError , FileNotFoundError ).

  • Educational Value: Show students how to handle errors gracefully.

  1. "No Magic Numbers"
  • Define constants for literal values.

  • ❌ if status == 4:

  • ✅ READY_STATUS = 4; if status == READY_STATUS:

Language-Specific Rules

Python

  • Style: Strict PEP 8.

  • Type Hints: Use type hints for function arguments and return values. def calculate_total(price: float, tax_rate: float) -> float: """Calculates total price including tax.""" return price * (1 + tax_rate)

  • f-strings: Prefer f-strings over % formatting or .format() .

JavaScript / TypeScript

  • Style: Standard JS style (Airbnb or similar).

  • Variables: Use const by default, let only when reassignment is needed. Never var .

  • Async/Await: Prefer async/await over raw Promises.

Pedagogical Patterns

  1. The "Before and After"

When teaching a better way to do something, show the "naive" approach first (labeled as such), then the "professional" approach.

  1. Progressive Complexity

Start with a minimal working example. Add complexity (error handling, edge cases) in subsequent steps.

  1. Runnable Snippets

Ensure code snippets are self-contained and runnable whenever possible. Include necessary imports.

Quality Checklist

Before finalizing any code snippet, verify:

  • Does it follow the language style guide?

  • Are variable names descriptive?

  • Are "magic numbers" replaced with constants?

  • Is there a docstring/comment explaining the purpose?

  • Is error handling appropriate for the context?

  • If it's a "bad example", is it clearly labeled?

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Research

research-methodology

No summary provided by upstream source.

Repository SourceNeeds Review
General

content-editing

No summary provided by upstream source.

Repository SourceNeeds Review
General

prose-generation

No summary provided by upstream source.

Repository SourceNeeds Review