AgentSkillsCN

python-header-note

为 Python 脚本添加全面的头部注释,包含题目陈述、算法解析,以及多种摘要变体(30 秒简述、快问快答版,以及超简洁的一行总结)。适用于为 Python 面试练习文件、算法实现,或教学脚本添加详尽的文档注释时使用。

SKILL.md
--- frontmatter
name: python-header-note
description: "Add comprehensive header notes to Python scripts with problem statements, algorithm explanations, and multiple summary variations (30-second pitch, rapid-fire version, and ultra-minimal one-liner). Use this skill when adding detailed documentation headers to Python interview practice files, algorithm implementations, or educational scripts."
license: Proprietary. LICENSE.txt has complete terms

Python Header Note Skill

Overview

This skill adds comprehensive header documentation to Python scripts, ideal for interview preparation, algorithm implementations, and educational content. It creates structured header notes with multiple summary levels and detailed explanations.

When to Use

Use this skill when you need to:

  • Add detailed header notes to Python algorithm files
  • Document interview practice problems and solution approach
  • Document design decisions and key concepts
  • Document multiple explanation formats (technical, pitch, rapid-fire)
  • utilize the note as a confidence booster and communication aid during interviews

For usage instructions: See README.md for detailed workflows on invoking this skill in Claude Code Agent and Copilot CLI.

Header Structure

A python-header-note should include:

  1. Problem Statement - Clear description of what the code solves
  2. Algorithm Explanation - How the solution works
  3. Summary Variations:
    • 30-second pitch (medium detail for quick understanding)
    • Rapid-fire version (key points only)
    • Ultra-minimal one-liner (core concept in a sentence)

Example Format

python
"""
## Problem Statement

[1-2 sentence problem description with goal and context]

## Whiteboard Coding Challenge Notes

* For this problem, I'm using [approach/algorithm name]:

[Brief overview of why this approach is suitable]

* Key Concepts:

  - [Concept 1: Why/How?]
[Detailed explanation with implementation considerations]

  - [Concept 2: Why/How?]
[Detailed explanation with implementation considerations]

* Logic:

1. [Step 1 description]
2. [Step 2 description]
3. [Step 3 description]
[Continue as needed]

* **30-Second Pitch**:

[Concise explanation suitable for quick verbal communication]

* **Rapid-Fire Version**:

- [Key point 1]
- [Key point 2]
- [Key point 3]

* **Ultra-Minimal One-Liner**:

- [Single sentence capturing the essence]

* **Complexity Analysis**:

- **Time Complexity:** [Expression with explanation]
- **Space Complexity:** [Expression with explanation]

* **Use Cases**:

[Where/when this solution is applicable]
"""

# Implementation code follows...

Step-by-Step Implementation Guide

1. Problem Statement Section

What to include:

  • Clear problem objective (1-2 sentences)
  • Key constraint or goal (space, time, specific requirement)
  • Context (why this matters in interviews)

Example:

code
Merge two sorted arrays in place without using extra space. 
The goal is to achieve this efficiently by minimizing comparisons and swaps. 
This tests understanding of in-place algorithms and optimization techniques.

2. Key Concepts Section

What to include:

  • 2-3 critical design decisions
  • For each: explain WHY (motivation) and HOW (implementation)
  • Include code snippets if they clarify the concept

Template for each concept:

code
- [What is this concept?]
[Why is it important? What problem does it solve?]
[How is it implemented? Any trade-offs?]

Example:

code
- Why initialize gap as `n + m` and reduce using `(gap + 1) // 2`?
The GAP method initialization to combined length ensures far-apart elements 
are compared first, resolving large inversions early. The reduction formula 
`(gap + 1) // 2` ensures controlled gap decrease, eventually reaching 1 for 
full sort completion.

3. Logic Section

What to include:

  • Numbered steps of the algorithm
  • High-level description (not pseudo-code, not line-by-line)
  • Flow and decision points

Format:

code
1. [Initialize variables with purpose]
2. [Define helper functions/structures with purpose]
3. [Main loop: what condition? what operations?]
4. [Termination: when and why does it stop?]

4. Interview Talking Points

Create three formats:

30-Second Pitch:

  • Natural speech pattern
  • Suitable for verbal explanation
  • Includes key algorithm name and main benefit

Rapid-Fire Version:

  • Bullet points
  • Key techniques and trade-offs
  • "What would you say if interrupted?"

Ultra-Minimal One-Liner:

  • Single sentence
  • Captures essence for quick reference
  • Includes algorithm name + complexity

Key Concepts to Explain

For most interview problems, address these design decisions:

QuestionWhy ExplainHow to Address
Why this algorithm?Shows problem understandingJustify vs alternatives
Why these data structures?Tests design knowledgeExplain space/time trade-offs
Why this initialization?Shows attention to edge casesExplain boundary conditions
Why these helper functions?Shows code quality thinkingExplain abstraction benefits
Why this formula/formula?Shows mathematical reasoningExplain derivation or inspiration

Common Pitfalls to Avoid

Too brief: "Use gap reduction" → ✅ "Initialize gap to n+m for early inversion resolution, reduce via (gap+1)//2 for controlled decrease"

Implementation details: Focus on WHY, not line-by-line HOW → ✅ Explain the concept, not every line of code

No complexity analysis: Always include time and space → ✅ Provide both with clear explanation

Single explanation: Redundant for interviews → ✅ Provide 3 formats (pitch, rapid-fire, one-liner)

Missing context: Assumes interviewer knows the problem → ✅ Always include Problem Statement section


Quality Checklist

Before finalizing a header note, verify:

  • Problem Statement is clear and interview-contextualized
  • Key Concepts explain WHY (motivation) not just HOW (implementation)
  • Logic section describes algorithm flow at high level
  • 30-Second Pitch is natural and conversational
  • Rapid-Fire Version uses clear bullet points
  • Ultra-Minimal One-Liner captures essence in one sentence
  • Complexity Analysis includes both time and space with explanation
  • Use Cases section contextualizes real-world applicability
  • No code implementation details in header (implementation follows below)
  • Consistent formatting and markdown structure

Tags

#interview-prep #documentation #header-note #skill #interview-coaching #algorithm-explanation #code-documentation