This file is the operating contract for AI agents working on this repository's website and its content/build integration.
The website is a static presentation layer over the learning repository. Agents must preserve that architecture.
Build and maintain a polished static learning website that presents the repository's Python notes, and later its practice material and projects.
The website must remain:
- static at production runtime;
- content-driven;
- deterministic;
- accessible;
- maintainable;
- consistent with
DESIGN.md; - compliant with
ARCHITECTURE.md; - safe to regenerate from repository source files.
The repository content is the source of truth. The website must not become the canonical storage location for learning notes.
Before making any meaningful change, inspect:
README.md
website/ARCHITECTURE.md
website/DESIGN.md
website/AGENTS.md
Then inspect the relevant active content under:
notes/
practice/
projects/
Do not use archived material as current website content unless the user explicitly asks for it.
When two instructions appear to conflict, use this priority order:
- Explicit user request in the current task.
- Repository architecture in
website/ARCHITECTURE.md. - Current visual requirements in
website/DESIGN.md. - Durable operating rules in this
AGENTS.md. - Existing implementation details.
- Agent assumptions.
Never let an implementation detail silently override the documented architecture.
Treat the repository as:
content source
↓
metadata/index generation
↓
static website build
↓
Cloudflare Pages
The current active content structure is:
notes/
├── index.md
├── metadata.json
├── notes-tracker.py
└── NN-topic/
└── NN-subtopic/
├── NN-note.md
└── NN-reference-file-K.py
Projects and practice will use the same philosophy later but are not fully implemented yet.
archive/ contains old material that the user explicitly wants to preserve without treating it as current learning content.
Agents must:
- never delete archive material merely to “clean up” the project;
- never automatically include archive content in public note navigation;
- never migrate archive files silently;
- never rewrite archived notes when normalizing active-note metadata.
Archive migration requires an explicit user-directed task.
Do not create one manually maintained React page per Markdown note.
Bad:
src/pages/IntegerPage.tsx
src/pages/FloatPage.tsx
src/pages/StringPage.tsx
Preferred:
one reusable note page
↓
metadata identifies requested note
↓
Markdown content is rendered dynamically from generated/static build data
New notes should become visible because content metadata changes, not because an agent writes another page component.
notes/index.md is a generated navigation manifest.
Agents must not manually patch its generated note entries to fix a navigation issue.
Instead:
- fix the source directory/file naming or tracker logic;
- run the tracker;
- inspect the generated result;
- build the website;
- verify the route.
If an intentional manually authored section is ever added to index.md, clearly separate it from generated content with a documented marker. Until then, treat the file as fully generated.
Never hand-edit notes/metadata.json to make the website work.
Fix the source or notes-tracker.py, then regenerate.
Metadata must remain derived from the current filesystem and note metadata.
Do not store complete Markdown bodies in metadata.json unless the architecture is deliberately revised.
Active Markdown notes may contain YAML frontmatter, but the canonical allowed fields are only:
---
date: YYYY-MM-DD
time: HH:MM:SS+TZ
---When maintaining notes/notes-tracker.py, ensure that it:
- preserves valid existing
date; - preserves valid existing
time; - adds missing values;
- removes all other YAML keys;
- does not add a new frontmatter block when one already exists;
- does not rewrite timestamps on every run just because the tracker was executed.
Do not store title, slug, tags, headings, route, or generated hashes in Markdown frontmatter under the current architecture.
Those belong in generated metadata when needed.
Active topic/subtopic/note filenames must have a numeric ordering prefix:
NN-name
Examples:
00-syntax-and-basics
01-operators
00-integer.md
01-float.md
The prefix controls ordering.
The displayed name and public URL must omit the numeric prefix.
Do not silently rename user content solely to make the UI prettier. Rename only when it is required by the content contract and the change is part of the requested task.
Ordering is numeric, not lexical.
The parser should understand a variable-width integer prefix, even though the repository convention normally uses two digits.
Examples:
00
01
02
10
11
Duplicate sibling order numbers must be treated as a validation error.
Do not invent alphabetical tie-breakers to hide malformed source structure.
By default, display titles come from the filename after removing:
- the
.mdextension; - the leading numeric prefix and hyphen;
- filename separators such as hyphens/underscores as appropriate.
Example:
00-integer.md
becomes:
Integer
Do not aggressively title-case acronyms or technical identifiers.
Do not introduce a second title source without updating ARCHITECTURE.md.
A Python reference file is associated with a note only when it follows the defined naming convention:
NN-reference-file-K.py
Example:
00-integer.md
00-reference-file-1.py
00-reference-file-2.py
Do not automatically attach every .py file in the directory to the note.
Reference files must be:
- discoverable by metadata generation;
- viewable in the note page;
- copyable;
- downloadable using their original filename.
No backend fetch may be required at runtime.
Production code must work as a static site.
Allowed:
- React;
- TypeScript;
- Vite;
- client-side routing;
- client-side state;
- build scripts;
- static JSON/data;
- build-time API requests for non-critical metadata;
- local browser storage for optional preferences.
Not allowed without an explicit architecture change:
- runtime backend;
- database dependency;
- authentication requirement;
- server-side Markdown fetching;
- server-rendered note pages;
- runtime GitHub token usage;
- API-dependent core note rendering.
Node.js is build tooling, not a production runtime requirement.
The website must remain a Vite project.
Use the Vite production build for deployable output:
npm run buildThe deployment artifact should be the generated dist/ directory unless vite.config.ts explicitly defines another documented output directory.
Do not introduce a second competing build system without updating ARCHITECTURE.md.
The intended deployment target is Cloudflare Pages.
The expected production relationship is:
Git repository
↓
Cloudflare Pages build
↓
npm run build
↓
dist
Do not add Cloudflare Workers/server functionality merely because Cloudflare supports it. The intended project is static.
SPA deep links must remain functional on Pages.
The global navbar includes:
Home (Brand Title: python-learning)
Notes
Projects
Practice
Links (Dropdown on desktop, dedicated route /links)
Donate (Clean CTA button — NO currency/rupee logo)
GitHub icon + Repository star badge
Mobile hamburger menu toggle (3 clean SVG lines -> SVG X)
The homepage includes a WebGL Ribbon Field hero and a Three.js Emerald Horizon footer (strictly adhering to the vignette: 0 zero vignette rule), with visual details governed by DESIGN.md.
Do not remove a navigation item to simplify implementation unless the user explicitly asks for it.
All full-screen mobile menu drawers must be rendered via createPortal(drawer, document.body) to avoid clipping and entrapment inside parent containers with CSS backdrop-filter.
The Notes landing page must expose the nested active topic structure.
Selecting a note must navigate to its actual note route.
Left (280px) = sticky topic/navigation panel
Middle = actual Markdown note content (max-width 820px)
Right (240px) = in-page Table of Contents + Reference Python files + Practice link
Left = off-canvas slide-out drawer (320px max) with backdrop blur, body scroll locking,
auto-close on note tap, and a floating 'Topics' pill button when closed.
Middle = primary reading area with touch-scrollable breadcrumbs,
collapsible 'On this page' Table of Contents accordion (< 1100px),
and stacked Prev/Next navigation cards.
The left region:
- highlights the current note;
- is hideable/collapsible;
- keeps the current branch visible.
The middle region:
- renders Markdown faithfully with Prism syntax highlighting;
- supports formatted code with copy feedback;
- provides horizontal touch scrolling for tables and code blocks.
The right region:
- derives its overview from Markdown headings;
- scrolls smoothly to the selected heading;
- lists reference
.pyfiles opening the in-page code viewer modal; - provides direct jump links to related Practice exercises.
The practice/ domain mirrors the exact same topic and subtopic folder hierarchy as notes/:
notes/NN-topic/NN-subtopic/NN-name.md
practice/NN-topic/NN-subtopic/NN-name.md
- When a practice file exists with the matching slug/name in the same subfolder structure as a note, the system treats them as a Connected Theory & Practice Pair.
- Note Detail UI: Must render a prominent "Practice Related Exercises" button in the overview/right panel linking directly to
/practice/<topic>/<subtopic>/<name>. - Practice UI: Must render a "View Theory Notes" button linking directly back to
/notes/<topic>/<subtopic>/<name>. - The content tracker must record these bidirectional routes in
metadata.json.
Heading IDs must be deterministic and unique.
Example:
## Overview
## Examples
## Overviewmust produce unique anchor IDs, such as:
overview
overview-2
The exact slug algorithm may evolve, but it must remain deterministic within a build.
The right-side overview must preserve heading hierarchy.
Do not include redundant metadata blocks as “headings” unless they are actual Markdown headings.
Reference code viewers should be reusable components.
Required behavior:
- show original filename;
- syntax highlight Python;
- copy contents;
- download contents;
- remain on the same note route;
- close cleanly;
- be keyboard accessible;
- support long code files.
The downloadable file must contain the actual source text, not rendered HTML.
Search must work without a backend.
Prefer build-generated searchable data over fetching the repository from GitHub at runtime.
Search should eventually cover:
- note title;
- topic/subtopic;
- headings;
- note body text;
- reference filenames when useful.
For performance, do not place the entire repository in one giant browser object unless the collection is demonstrably small.
Every feature must consider keyboard and screen-reader use.
Minimum requirements:
- semantic landmarks;
- keyboard-focusable controls;
- visible focus;
- meaningful labels on icon-only buttons;
- accessible dialogs/overlays;
- no keyboard traps;
- reduced-motion support;
- sufficient contrast;
- responsive reading layout.
Never sacrifice accessibility just to match a visual effect.
Treat Markdown and Python content as input data.
Never:
- execute note code in the browser;
- inject unsanitized HTML from Markdown;
- interpolate filenames directly into trusted HTML without escaping;
- trust user-controlled route parameters without validation;
- allow path traversal outside repository content roots.
Code snippets are for display/download unless a future explicit execution sandbox is designed.
This repository is expected to be usable across Windows and Linux/WSL workflows.
Use:
- repository-relative paths;
- forward slashes in generated metadata/routes;
- path libraries rather than hard-coded separators;
- UTF-8 file encoding;
- explicit newline handling when necessary.
Do not assume / or \\ when writing Python path logic manually.
When a script generates:
notes/index.md
notes/metadata.json
it should, where practical:
- scan and validate;
- construct the complete result in memory/temp storage;
- write the result atomically.
The goal is to avoid leaving corrupted/truncated generated files if the process fails halfway through.
Before changing code:
- inspect the relevant source structure;
- identify the authoritative file;
- check
ARCHITECTURE.mdfor constraints; - check
DESIGN.mdfor visual constraints; - make the smallest coherent change;
- regenerate generated artifacts;
- run validation/build;
- inspect the actual result;
- report what changed.
Do not modify unrelated areas merely because they are nearby.
A website change is not done merely because TypeScript compiles.
For meaningful changes, verify as applicable:
content generation
↓
metadata generation
↓
website build
↓
static preview
↓
route behavior
↓
visual behavior
↓
accessibility basics
Check both:
- the source repository;
- the resulting website behavior.
Agents must not:
- delete notes;
- delete archive files;
- rewrite large sets of notes for formatting reasons;
- rename many files without explaining why;
- remove user content because it is unused;
- discard old metadata without a source-of-truth explanation.
Preserve content unless removal is explicitly requested.
Agents must never create the final website commit merely because their implementation is complete.
The workflow is:
Agent modifies files
↓
Agent validates/builds
↓
Agent shows result/status to user
↓
User inspects
↓
User explicitly approves
↓
Commit website changes
A user saying that the task is “done,” “looks good,” “approved,” or otherwise explicitly authorizing the finished changes counts as approval.
Until explicit approval is received, do not create the website commit.
Website commits must use the format:
(website-update-N) - <summary>
Examples:
(website-update-1) - Initial static notes interface
(website-update-2) - Add Markdown note rendering
(website-update-3) - Add reference code viewer
N is a monotonically increasing website-update number.
Do not guess a previous number. Inspect Git history and continue the sequence.
The summary should describe the actual approved website change.
Before an approved website commit:
- inspect
git status; - inspect the staged diff;
- ensure unrelated user changes are not accidentally staged;
- include generated files only when they are intended outputs of the change;
- do not stage archive changes unless explicitly requested.
A commit must not contain surprise formatting sweeps or unrelated refactors.
This file is intended to accumulate durable project-specific instructions.
When the user provides a new preference or rule that should apply to future work, agents should:
- identify whether it is durable rather than task-specific;
- add a concise rule to this
AGENTS.mdunder the most appropriate section; - avoid duplicating an existing rule;
- preserve the user's intent;
- tell the user that the preference has been incorporated into the agent rules.
Examples of durable preferences:
- navigation conventions;
- naming conventions;
- approval requirements;
- code-quality rules;
- animation behavior;
- recurring interaction preferences;
- preferred development commands.
Do not record secrets, credentials, tokens, or highly personal information.
Update ARCHITECTURE.md when a change affects:
- source-of-truth rules;
- data flow;
- file schemas;
- route conventions;
- build/deployment model;
- generated artifact contracts;
- content hierarchy;
- major component boundaries;
- static-vs-runtime responsibilities.
Do not change architecture documentation merely to describe a small bug fix.
Update DESIGN.md when a durable visual rule changes, such as:
- typography;
- colors;
- spacing system;
- hero behavior;
- footer behavior;
- responsive layout;
- animation language;
- component appearance;
- interaction visuals.
Do not put visual styling rules into ARCHITECTURE.md merely because an agent needs them to implement a component.
Do not introduce a new library merely because it is popular.
Before adding a dependency, ask:
- does the current stack already solve this?
- does it support static output?
- does it increase bundle size significantly?
- does it complicate build-time content handling?
- does it create a runtime backend dependency?
- is it compatible with the repository's architecture?
Prefer the smallest dependency set that gives a strong result.
The website should consume typed content models, not raw filesystem strings scattered across UI components.
Conceptual model:
Note
├── id
├── title
├── route
├── sourcePath
├── order
├── date
├── time
├── headings[]
├── references[]
└── contentReact components should receive this model rather than knowing how to parse numeric filename prefixes or discover sibling Python files.
Parsing belongs in content/build utilities.
Only a small number of functions should understand filename conventions.
Centralize:
parseOrderPrefix();displayNameFromPath();slugFromPath();resolveReferenceFiles();normalizeFrontmatter();generateHeadingIds().
Do not duplicate prefix stripping logic in five different React components.
When validation fails, print:
- the exact source path;
- the rule that failed;
- what the agent/user should change.
Bad:
Invalid content
Good:
Duplicate note order `02` in:
- notes/00-syntax-and-basics/00-vars/02-string.md
- notes/00-syntax-and-basics/00-vars/02-bool.md
Rename one note so sibling order is unique.
The generated notes/index.md should reflect the exact active filesystem state.
The index must:
- include all active topics/subtopics/notes;
- exclude archive content;
- exclude generated helper files;
- hide numeric prefixes;
- preserve numeric ordering;
- be deterministic.
Do not create a second manually maintained navigation tree in the website source.
Public note URLs should omit numeric ordering prefixes.
Example:
source:
notes/00-syntax-and-basics/00-variables-and-datatypes/00-integer.md
public route:
/notes/syntax-and-basics/variables-and-datatypes/integer
Do not put filesystem paths with NN- prefixes into user-visible URLs unless the architecture is explicitly changed.
Treat note moves/renames as content operations, not cosmetic changes.
After any move/rename:
- regenerate metadata;
- regenerate index;
- verify route changes;
- check internal links;
- build the site;
- inspect navigation.
Never leave stale generated references.
The current repository star count is a non-critical enhancement.
Rules:
- it must not block note rendering;
- no secret token may be exposed to the client;
- a failed metadata fetch must have a fallback;
- do not poll GitHub from every browser visit;
- prefer build-time or pre-generated data.
The exact scripts may evolve, but the intended workflow is:
# validate/generate content
python notes/notes-tracker.py
# install/build website
npm install
npm run build
# preview production build
npm run previewThe tracker may eventually expose explicit subcommands such as:
python notes/notes-tracker.py check
python notes/notes-tracker.py normalize
python notes/notes-tracker.py generateIf implemented, document them in the tracker itself and keep their behavior deterministic.
The website must remain usable if GitHub is down after deployment.
Therefore:
- note content must be packaged into the static build;
- navigation must be packaged into the static build;
- reference Python files must be packaged into the static build;
- the site must not fetch raw Markdown from GitHub at runtime for core pages.
External links are fine; core note rendering must be local to the built site.
After a successful production build, the website's core content should work without internet access, apart from intentionally external services such as external links or optional live metadata.
This is a useful architectural test:
Build complete
↓
disconnect network
↓
serve dist/
↓
Notes should still render
For UI work, do not assume that successful compilation means the design is correct.
Inspect the rendered result and verify:
- spacing;
- overflow;
- typography;
- mobile behavior;
- topic panel behavior;
- overview alignment;
- code viewer usability;
- footer/hero integrity.
Follow DESIGN.md rather than inventing a different style language.
47. Avoid Hidden State Bugs
The route is the source of truth for which note is open.
Do not make the selected note depend only on a React state variable that disappears on refresh.
Optional UI state such as sidebar collapsed/open can be local state or local storage, but it must not change the note identity.
On smaller screens, the three-column note layout may collapse into a staged/mobile layout, but all information must remain accessible.
At minimum:
- note content remains primary;
- topic navigation becomes an accessible drawer/sheet/section;
- overview remains reachable;
- reference files remain reachable;
- no horizontal page overflow is introduced.
Exact visual breakpoints belong in DESIGN.md.
Do not prematurely build a complete practice/projects system.
However, new website code should avoid naming everything specifically around notes when a general content abstraction is cheap and clear.
Prefer:
ContentSection
over deeply hard-coded logic such as:
if path starts with /notes everywhere
Keep the first implementation simple while preserving this extension point.
Before presenting a completed implementation:
[ ] Read AGENTS.md
[ ] Read ARCHITECTURE.md
[ ] Read DESIGN.md
[ ] Identify source-of-truth files
[ ] Do not modify archive content unnecessarily
[ ] Keep static production architecture
[ ] Keep Vite + React + TypeScript
[ ] Keep numeric-prefix ordering semantics
[ ] Keep NN- hidden from display/routes
[ ] Keep frontmatter limited to date/time
[ ] Regenerate index/metadata from source
[ ] Validate route collisions
[ ] Validate reference files
[ ] Validate heading IDs
[ ] Build successfully
[ ] Inspect rendered website
[ ] Check responsive behavior where relevant
[ ] Check accessibility basics
[ ] Inspect git diff/status
[ ] Do NOT commit until user explicitly approves
[ ] After approval use (website-update-N) - ...
[ ] Add new durable preferences to AGENTS.md when appropriate
At the current stage, the agent's primary implementation scope is:
notes/
website/
The intended next major implementation is notes/notes-tracker.py, followed by the Vite/React website implementation.
Practice/projects behavior is intentionally deferred.
When in doubt:
Preserve the repository's content, keep the website statically buildable, derive website state from source content, obey
ARCHITECTURE.mdandDESIGN.md, and wait for explicit user approval before committing website changes.
Always use these standard commands:
# Normalize and synchronize note metadata (from repo root)
python3 notes/notes-tracker.py normalize
# Check metadata integrity (from repo root)
python3 notes/notes-tracker.py check
# Build static production bundle into website/dist/
cd website && npm run build
# Preview static build locally
cd website && npm run preview- Hero: Ribbon Field WebGL (
RibbonFieldBackground) with continuous slow hue cycling and pointer drift. - Footer: Emerald Horizon Three.js (
EmeraldHorizonBackground) with synchronized hue cycling andvignette = 0(zero vignette rule). - Both animations preserve aspect ratio (
object-fit: coverlogic with crop, never stretching/distorting).