Skip to main content
ClaudeWave
Skill65 repo starsupdated yesterday

programming-fundamentals

Core programming concepts from variables through recursion. Covers data types (integers, floats, strings, booleans, arrays, objects), variables and scope (lexical, dynamic, block, function, global), control flow (conditionals, loops, pattern matching), functions (parameters, return values, closures, higher-order functions), recursion (base cases, call stack, tail recursion, mutual recursion), type systems (static vs dynamic, strong vs weak, type inference, generics), and error handling (exceptions, Result types, defensive programming). Use when teaching, reviewing, or diagnosing issues with fundamental programming constructs.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/Tibsfox/gsd-skill-creator /tmp/programming-fundamentals && cp -r /tmp/programming-fundamentals/examples/skills/coding/programming-fundamentals ~/.claude/skills/programming-fundamentals
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Programming Fundamentals

Programming is the act of giving precise instructions to a machine. Every program, from a one-line script to a distributed system, is built from a small set of fundamental constructs: variables that name values, control flow that directs execution, functions that encapsulate logic, types that constrain data, and error handling that manages the unexpected. This skill catalogs these constructs with emphasis on the mental models that make them learnable and the pitfalls that make them treacherous.

**Agent affinity:** hopper (practical language implementation, debugging), papert (pedagogical scaffolding, constructionist learning)

**Concept IDs:** code-variables-data-types, code-control-flow, code-input-output, code-syntax-style

## Part 1 -- Variables and Data Types

A variable is a name bound to a value. The binding may be mutable (the name can be rebound to a different value) or immutable (the binding is permanent). The value itself has a type that determines what operations are valid.

### Primitive Types

| Type | Examples | Key operations | Gotchas |
|---|---|---|---|
| Integer | 42, -7, 0 | Arithmetic, comparison, bitwise | Overflow (wrapping vs saturating vs panic) |
| Float | 3.14, -0.001, NaN | Arithmetic, comparison | IEEE 754 precision: 0.1 + 0.2 != 0.3 |
| Boolean | true, false | AND, OR, NOT, short-circuit | Truthy/falsy coercion in dynamic languages |
| Character | 'a', '\n', Unicode code point | Comparison, encoding/decoding | Char != string of length 1 in all languages |
| String | "hello", "" | Concatenation, slicing, search | Mutable vs immutable, encoding (UTF-8 vs UTF-16) |

**The floating-point trap.** IEEE 754 floats represent real numbers in binary. Most decimal fractions (0.1, 0.2, 0.3) have no exact binary representation. Comparing floats with == is almost always wrong. Use an epsilon tolerance: abs(a - b) < epsilon. For money, use integers (cents) or decimal types.

### Composite Types

**Arrays / Lists.** Ordered, indexed collections. Fixed-size arrays (C, Rust) vs dynamic arrays (Python list, JavaScript array, Java ArrayList). Index from 0 in most languages (Lua and MATLAB from 1).

**Objects / Records / Structs.** Named fields grouping related data. In OOP languages, objects also carry methods. In functional languages, records are plain data without behavior.

**Tuples.** Fixed-size, heterogeneous, ordered collections. Useful for returning multiple values from a function. Destructuring assignment extracts components.

**Maps / Dictionaries.** Key-value pairs with O(1) average lookup. Keys must be hashable (immutable in Python). Ordered by insertion in Python 3.7+ and JavaScript, unordered in most other languages.

### Scope and Lifetime

**Lexical (static) scope.** A variable is visible in the block where it is defined and all nested blocks. This is the default in most modern languages. The scope is determined by the program text, not the runtime call chain.

**Dynamic scope.** A variable is visible to the function that defined it and all functions it calls (transitively). Rare in modern languages. Emacs Lisp uses dynamic scope by default; Common Lisp offers it via special variables.

**Block scope vs function scope.** JavaScript's var is function-scoped; let and const are block-scoped. This distinction is the source of many bugs involving closures and loops.

**Lifetime.** How long a value exists in memory. Stack-allocated values live until the enclosing function returns. Heap-allocated values live until freed (manual in C, automatic via garbage collection or ownership in Rust).

**The closure capture question.** When a closure captures a variable, does it capture the variable itself (by reference) or its current value (by value)? This matters critically in loops. In JavaScript, `var` in a loop captures by reference (all closures see the same variable); `let` captures by value per iteration.

## Part 2 -- Control Flow

### Conditionals

**if/else** is the fundamental branch. Every programming language has it. The condition must evaluate to a boolean (in statically typed languages) or a truthy/falsy value (in dynamically typed languages).

**Switch/match.** Multi-way branching. C-style switch requires explicit break (fall-through by default). Modern languages (Rust match, Python match, Kotlin when) do not fall through and support pattern matching.

**Pattern matching.** Destructures values while testing conditions. Rust's match and Haskell's case are exhaustive -- the compiler ensures all patterns are covered. This eliminates entire classes of bugs.

**Ternary operator.** `condition ? true_value : false_value`. Syntactic sugar for a simple if/else that returns a value. Overuse reduces readability.

### Loops

**for loop.** Iterate a known number of times or over a collection. C-style `for (init; test; step)` vs for-each `for (item of collection)`.

**while loop.** Iterate while a condition holds. Checked before each iteration. The condition must eventually become false, or the loop never terminates.

**do-while.** Like while but the body executes at least once. Less common in modern code.

**Loop invariants.** A property that is true before the loop, maintained by each iteration, and true after the loop. Stating the invariant explicitly is the most reliable way to reason about loop correctness. Dijkstra emphasized this throughout his career.

**Infinite loops.** `while (true)` with an internal break. Used in event loops, servers, and REPL implementations. Always ensure there is a reachable exit condition.

**The off-by-one problem.** The most common loop bug. "Should I use < or <=? Start at 0 or 1?" The fix is to state the loop invariant and verify the boundary conditions: does the first iteration do the right thing? Does the last iteration do the right thing? What happens on empty input?

### Iteration vs Recursion

Every loop can be rewritten as recursion and vice versa. Loops are typically more efficient (no call stack overhead) a
art-history-movementsSkill

Major art movements and their historical context for art education. Covers 12 movements from the Renaissance to contemporary art, their defining characteristics, key artists, signature works, and the intellectual/social forces that produced them. Use when analyzing artworks in historical context, understanding stylistic lineages, identifying influences across periods, or connecting studio practice to art-historical precedent.

color-theorySkill

Color theory principles for art education. Covers the three color properties (hue, saturation, value), color mixing systems (subtractive and additive), color relationships (complementary, analogous, triadic, split-complementary), color temperature, simultaneous contrast and the relativity of color perception, and practical palette construction. Use when analyzing color in artworks, planning color schemes, understanding optical phenomena in painting, or investigating Albers's Interaction of Color experiments.

creative-processSkill

The creative process in art from idea to exhibition. Covers five phases of creative work (inspiration, incubation, exploration, execution, reflection), sketchbook practice, artist statements, critique methodology (formal and conceptual), portfolio development, and the studio as a working environment. Use when guiding students through project development, facilitating critique sessions, developing artist statements, curating portfolios, or understanding how professional artists structure their creative practice.

digital-artSkill

Digital art tools, techniques, and workflows for art education. Covers raster and vector workflows, digital painting, photo manipulation, generative and procedural art, 3D modeling and rendering, pixel art, the relationship between traditional skills and digital execution, and ethical considerations of AI-generated imagery. Use when working with digital tools, evaluating digital art, or bridging traditional art concepts into digital practice.

drawing-observationSkill

Observational drawing and visual perception techniques for art education. Covers contour drawing, gesture drawing, negative space, proportion and measurement, value mapping, spatial depth cues, and the cognitive shift from symbolic to perceptual seeing. Use when teaching drawing fundamentals, analyzing observational accuracy, or developing visual literacy in any medium.

sculpture-3dSkill

Three-dimensional art and sculptural thinking for art education. Covers additive and subtractive sculptural processes, armature construction, modeling in clay, carving principles, casting and moldmaking, assemblage and found-object sculpture, installation art as expanded sculpture, and the conceptual transition from pictorial to spatial thinking. Use when working with three-dimensional media, analyzing sculptural form, understanding spatial composition, or investigating the relationship between sculpture and site.

celestial-coordinatesSkill

Celestial coordinate systems and sky positioning. Covers horizon (altitude-azimuth), equatorial (right ascension-declination), ecliptic, and galactic systems; epoch and precession; coordinate transformations; planisphere use; and practical sky-locating from any latitude and date. Use when locating objects, planning observations, converting catalog coordinates, or teaching the geometry of the sky.

cosmological-observationSkill

Observational cosmology from Hubble's law to the CMB. Covers redshift, Hubble expansion, the cosmological parameters, the cosmic microwave background, large-scale structure, galaxy rotation curves and dark matter, Type Ia SNe and dark energy, and the current state of Lambda-CDM. Use when reasoning about the large-scale universe, interpreting cosmological surveys, or teaching the Big Bang evidence chain.