We have the most powerful AI coding agents in history running right in our terminals, yet when it comes to researching our own documents, they still lack basic boundaries.
Point a standard agent at a local folder of PDFs, books, or notes and ask it to synthesize a concept. Half the time, it acts like an overly eager intern—confidently hallucinating a paper that doesn't exist, or blending three different authors into one contradictory mess.
Google completely solved this friction point with NotebookLM (recently rebranded to Gemini Notebook). It grounded the AI to a strict set of provided sources, killing the hallucination engine and forcing verifiable citations. It is brilliant. But it’s also a closed, cloud-only ecosystem.
I love the concept, but I wanted that exact magic running completely open-sourced, and accessible to any AI agent I happened to be using in my terminal.
So, I built it.
agentic-notebook turns any local folder of documents into a strictly grounded research workspace for your AI agent.
Point your agent at a directory, and the skill indexes everything inside it into a local .notebook/ directory. From that moment on, the agent answers questions only from those sources. No invented sources. No guessing.
Key Features:
[1] book.pdf · p.41 · "exact quote from the page").--ocr-lang (e.g. --ocr-lang deu+eng)..noteignore support. Drop a .noteignore file at the folder root to keep files out of the index using simple gitignore-style globs (drafts/, *.log). Add a pattern later and the already-indexed matches are pruned on the next run..notebook directory. However, keep in mind that if you use a cloud-based agent like Claude Code or Copilot, the agent will still read this data to generate its answers. Keep highly sensitive personal data out unless you are pairing this tool with a strictly local LLM.agentic-notebook now ships in two flavors, so you can match it to whatever model you're running:
agentic-notebook — the full-power variant, tuned for frontier/large models.agentic-notebook-mini — a lean variant built for small local models (7–14B) running via Ollama, llama.cpp, LM Studio, or vLLM. It adds a disk-backed task ledger, fused compact search, --toc skimming for quick document overviews, and command quotas to keep smaller models on-track.Pick the full variant when you have headroom; reach for mini when you're running fully local on modest hardware.
Because it’s built on the skills CLI standard, it works out of the box with Claude Code, Gemini CLI, Cursor, Codex, Copilot, OpenCode, and virtually any other modern agent.
To install it globally, run:
npx skills add Harduex/agentic-notebook
# pick the variant (agentic-notebook or agentic-notebook-mini) when prompted
(Claude Code users can alternatively grab it as a plugin. Add the marketplace, then install whichever variant you want:)
/plugin marketplace add Harduex/skills
/plugin install agentic-notebook@harduex # frontier / large models
/plugin install agentic-notebook-mini@harduex # small local models
Once installed, just point it at your target folder with a natural language prompt:
Act as a notebook over ./my-books — what do these authors disagree about on mastering loudness?
On the first run, the tool quietly spins up the .notebook workspace and indexes the files. After that, you have a completely grounded research assistant.
Retrieving facts is just the baseline. Where this tool really shines is when you start combining it with other agentic skills.
For example, you can stack it with Matt Pocock's excellent teach skill. Point agentic-notebook at a folder full of complex programming books or lesson materials to index the raw knowledge, and then invoke the teach skill to have the agent actively tutor you based only on the verifiable facts from those specific books. You can ask for flashcards, study guides, quizzes, briefing docs, timelines, or mind maps, and every single answer will be strictly backed by your actual files.
You need Python 3.9+ installed on your system, and optionally tesseract (or easyocr) if you want to parse scanned books. But the bundled scripts prioritize the standard library, keeping the footprint light and auto-detecting PDF libraries when present.
The scripts themselves are plain, readable Python. As you always should with any skill that ships scripts, read them before installing.
We are moving past the era of just throwing raw text at an LLM and hoping for the best. Context is everything.
Your agent finally has a structured memory. Time to ask better questions.
]]>Switch to Wayland, they said. It's the future, they said.
And it is—especially with the sleek new Pop!_OS COSMIC desktop. But when it came to managing my clipboard history, the ecosystem felt unpolished. I tried almost every clipboard manager out there. Most were either buggy, bloated, missing crucial features, or forced a rigid UI that completely clashed with my system's aesthetic.
I didn't want to adapt my workflow to a buggy app. I wanted an all-in-one solution that met a very strict set of criteria:
Super+V (the standard Windows-style muscle memory).Nothing out there checked every single box.
So, I built it myself.
copyzen is a minimalist, daemon-free Wayland clipboard manager built specifically for Pop!_OS COSMIC and other Wayland compositors.
Instead of building a massive app, copyzen acts like a silent backend. It uses standard tools (wl-clipboard for the heavy lifting and fuzzel for the UI) to give you a blazing-fast, entirely customizable clipboard history.
Here is what makes it different:
Enter (or click) to select the item you want, and it instantly loads into your active clipboard. Then, just paste normally with Ctrl+V wherever you are.Ctrl+S on any entry in the picker to pin it. Pinned entries get a ★, jump to the top of your list, and survive total history wipes.copyzen fixes this. It keeps images alive in the background and even generates thumbnail previews right in your picker.Ctrl+Shift+D deletes a specific snippet, and Ctrl+Shift+C wipes your history entirely (leaving your pinned favorites safe).fuzzel as the frontend, it inherently respects your system's styling and scaling. It doesn't look like a bolted-on third-party app; it looks like it belongs there.It's not a bloated Swiss Army knife. It's a single, perfectly sharpened blade.
I wanted the installation to be as frictionless as using the tool itself. As long as you have wl-clipboard and fuzzel installed on your system, you can grab the latest version of copyzen with a single command.
Drop this into your terminal:
# Downloads, verifies, and installs copyzen and its background service
curl -fsSL https://github.com/Harduex/copyzen/releases/latest/download/install.sh | sh
The script sets up everything automatically—the binaries, the background watcher, and the configuration. It is completely idempotent, meaning you can run it again later to update.
To make it truly seamless, you just need to bind it to a shortcut. If you are daily-driving COSMIC:
copyzen-menuSuper+V (or whatever combo you prefer).Press Super+V, find your snippet, hit Enter, and paste it.
Since copyzen relies entirely on fuzzel for its user interface, customizing it is incredibly straightforward. During installation, a scoped configuration file is automatically created for you.
To change how the picker looks—whether you want to tweak the colors, adjust the font, or set the perfect opacity to match your desktop's theme—simply edit the configuration file located at:
~/.config/copyzen/fuzzel.ini
Inside this file, you can define your own aesthetic without affecting other tools on your system. You can tweak everything from background transparency and text colors to the exact border widths, paddings, and fonts you prefer.
When the ecosystem doesn't have the exact tool you need, you have two choices: compromise your workflow, or open your code editor.
I built copyzen because I was tired of compromising with buggy clipboard managers. If you've been looking for a Wayland solution that respects your memory, your workflow, and your aesthetic, give it a try.
Happy copying!
]]>You spend three hours wrestling with an AI coding agent. You debate architecture, run long debugging session, write a temporary bash script to parse the logs, and finally—it works. The feature is done. You commit the code. You close the chat.
And just like that, the agent forgets everything.
You kept the final product, but you threw away the machine that built it.
Most developers treat AI chat sessions as disposable scratchpads. The back-and-forth iteration is viewed as the messy, temporary scaffolding needed to build a working feature. But if you want to be Agentic Engineer instead of a Vibe Coder, this scaffolding shouldn't be treated as a waste. It's actually totally the opposite - the blueprint for building and constantly improving your agentic harness.
When a master blacksmith creates a legendary sword, they don't smash the mold afterward. They keep it so they can forge the next one effortlessly. The real leap in working with AI coding agents isn't about writing better one-shot prompts. It's about designing systems that learn form your daily chat logs and crystallize that residue into permanent, reusable skills.
Let's look at how to build an agent that actually learns from your interaction with it.
If you try to force a multi-step, dynamic workflow into a static instruction file (AGENTS.md), you are fighting a losing battle.
Most developers conflate instructions with skills. They dump routing logic, data-parsing rules, and twenty-step standard operating procedures into one massive system prompt. That is an instruction file, and it is a trap. It leads to context pollution, memory degradation, and an agent that forgets step three by the time it reaches step seven.
We are moving firmly into the era of Software 3.0. We aren't just writing code anymore; we are engineering harnesses—living, dynamic environments built on modular capabilities. To do that, you have to separate your rules from your workflows:
A static instruction prompt just gives orders. A harness uses skills to execute.
A good harness updates its own toolbelt. Here are the four mental models to make that happen.
If you are manually editing an agent's custom instructions or system prompt, you are working too hard.
The Concept: The agent must act as its own memory manager. Instead of you constantly correcting its formatting, reminding it to use a specific linter, or adjusting its architectural defaults, the agent dynamically updates its own style and memory documents at runtime.
The Frictionless Cycle: At the end of a highly productive chat session, you don't just close the window. You trigger a wrap-up phase. You tell the agent:
"Review this session. Extract the non-obvious lessons about how I prefer to structure React components, and update your memory file."
It captures the nuance right when the context is richest. Tomorrow, when you open a new session, the agent reads that updated memory file first. It's just-in-time learning, minus the manual data entry.
When a major feature ships, the git and the chat history represent a highly specific, successful path through a dark forest of bugs and bad ideas.
The Concept: The post-mortem. When the PR is merged, the model scans the raw trail of design discussions, failed trials, and code reviews to extract the optimal workflow.
Crystallization: You take the process residue—the temporary plans, the research docs, the sprawling chat sessions, the git commit history—and instruct the agent to condense them into a high-value permanent asset. But instead of just writing passive documentation, you extract a repeatable pattern.
Let’s say you just spent two days grinding out a complex "Image" file entity for your app. You know "Video" and "Audio" entities are coming down the pipeline. Instead of starting from scratch next month, you instruct the agent to mine the session and generate an adding-file-entity skill based on exactly how you built the first one.
You aren't just saving the final code. You are capturing the scaffolding—how the database migrations need to look, which API routes need updating, and what testing edge cases matter. You are automatically promoting a messy, one-off implementation into a permanent factory that can churn out similar features on command.

During a heavy development session, agents often write throwaway helper scripts to parse data, mock a database, or run a specialized test. Don't let those utilities die in the chat history. Instruct the agent to audit its own session, isolate those utility scripts, and write procedural wrappers for them.
You are converting unstructured, ephemeral chat capabilities into structured, declarative skills.
I kept running into this exact friction myself—building complex transient workflows and then losing them to the chat history abyss the moment I closed my terminal. So, I built a tool to automate the harvest.
extract-skill-from-sessionTo bridge the gap between a messy chat and a permanent tool, I built extract-skill-from-session, a dedicated utility skill designed to strip the noise and keep the capability.
With this running, the next time your agent needs to validate a payload or mock a database, it won't have to invent a way to do it. It will just reach into its toolkit and pull out the exact utility it forged yesterday.
If you find yourself repeatedly telling your agent to "stop being so verbose" or "explain this more intuitively," your developer harness is leaking.
The Concept: Cosmetic isolation. You define a dedicated output-style file that controls exactly how your AI coding agent formats its responses—governing its verbosity, visual structure, headings, code-block layouts, and depth of explanations.
The Standing Rules: The power lies in keeping presentation entirely separate from behavioral instruction. You give the agent two strict guidelines:
set-output-style skill to instantly initialize your personalized style on any new machine you use.If you want to jumpstart this process, you don't have to build all these extraction tools from scratch. The capabilities we just discussed—extracting workflows, defining output styles, and managing agent memory—have been crystallized into a ready-to-use toolkit.
You can find my personal skills bundle here: The Evolving Harness Skills Repository.
This bundle contains a suite of modular agent skills specifically designed to help your AI coding assistant learn and adapt. It includes tools like:
extract-skill-from-session: Automatically condenses complex chat workflows into reusable, permanent skills.save-learned-lessons: Captures user chat session lessions and learns form corrections, routing lessons to the appropriate skill, documents and memory.using-evolving-harness: A master routing skill that orchestrates tasks through correct lifecycle phases and automatically runs the evolution loop at the end of a session.set-output-style: Dynamically manages and applies your preferred output formatting and verbosity.How to use it:
You can install this bundle directly into Claude Code using the official plugin marketplace. In your Claude Code CLI, simply run:
/plugin marketplace add Harduex/skills
/plugin install harness-evolution@harduex
/reload-plugins
Alternatively, if you are using the Agent Skills package manager, you can install the catalog directly into your project by running:
npx skills add Harduex/skills
Once installed, your agent can invoke them dynamically. When you finish a tough debugging session, you just say, "Run extract-skill-from-session," and the agent will handle the rest—turning your disposable chat into a permanent asset.
We are moving past the era of the disposable chat.
When you start treating your daily interactions not as one-off conversations, but as the foundational training data for your own personalized AI harness, the compounding returns are staggering. You stop solving the same problems twice. Your agent stops making the same formatting errors. You stop starting from zero.
We are no longer just writing code.
We are building the minds that write it.
]]>
Roughly half of the code being pushed to GitHub right now was written — or heavily co-written — by a machine. AI agents pick up real tickets, work for hours without supervision, run the tests, fix their own mistakes, and open pull requests while we sleep. If you blinked somewhere around 2022, this looks like it happened overnight.
It didn't. This "overnight success" took seventy-five years.
And like every good origin story, it is full of false starts, forgotten geniuses, embarrassing public failures, and one quiet insight that changed everything. Let's rewind the tape. All the way.
In 1950, Alan Turing asked the question that started it all: can machines think? But hiding right behind it was a more dangerous question — one that would take far longer to answer: can machines act?
Twenty years later, we got the first glimpse. Terry Winograd's SHRDLU (1970) let you type "pick up the red block and put it on the green cube" — and a virtual robot arm actually did it. It parsed your intent, made a plan, and executed it. The world it lived in was a tiny simulated tabletop, but the loop — understand, plan, act — was there, fully formed, half a century early.
Then in 1986, Marvin Minsky dropped a philosophical bomb called The Society of Mind. Intelligence, he argued, is not one big brilliant thing. It is thousands of small, simple agents cooperating — none of them smart on their own, all of them smart together.
Nobody knew it at the time, but Minsky had just sketched the multi-agent architecture running inside your terminal today.
The nineties made it official. Researchers gave the software agent its textbook definition — autonomous, reactive, proactive, social — and built entire academic empires around it: BDI architectures (Belief–Desire–Intention), multi-agent systems, "software assistants" that were supposed to book our flights and filter our email.
In parallel, another group was quietly solving the deeper problem: how does an agent learn? Reinforcement learning — Q-learning (1989), the reward signal, trial and error formalized into mathematics — gave us the theory of a machine that improves through experience.
So by the year 2000, we had the full recipe for agentic AI.
What we didn't have was fire. The compute and the data simply did not exist yet. And so the agents stayed trapped in textbooks and toy demos for another two decades — a blueprint waiting for an engine.
The engine arrived in pieces.
First, DeepMind showed a neural network teaching itself to play Atari games from raw pixels — no rules given, just a score to maximize. Then, in March 2016, came the moment the whole world watched: AlphaGo versus Lee Sedol. In game two, the machine played the now-legendary Move 37 — a move so alien that commentators assumed it was a bug. It wasn't. It was brilliance no human had considered in 2,500 years of Go.
For the first time, a machine displayed something that looked suspiciously like taste.
But these agents were savants: superhuman at exactly one thing, useless at everything else. The missing piece landed quietly in 2017, in a paper with a rockstar title — "Attention Is All You Need." The Transformer architecture. Almost nobody outside the field noticed.
The dream finally had its engine.
GPT-3 (2020) proved a single model could follow instructions for almost anything. Its coding sibling Codex became GitHub Copilot (2021) — the first AI tool millions of developers actually used. But let's be honest about what it was: autocomplete. A brilliant, shy copilot that suggested the next line and never, ever touched the controls.
The real unlock came in 2022, and it fit in one acronym: ReAct — Reason + Act.
The insight sounds almost trivial: instead of asking a model for one big answer, let it think, act, observe, and think again. Reason about the problem, run a search or execute some code, look at the result, adjust, repeat. A language model placed inside that loop, with tools in its hands, stops being a text generator.
It becomes an agent.
A few months later, in November 2022, ChatGPT launched — and the entire world suddenly understood what these models were. The stage was set for chaos.
Spring 2023. Two open-source projects — AutoGPT and BabyAGI — asked the obvious question: what if we just give GPT-4 a goal and let it run in a loop, unsupervised?
The internet lost its mind. Hundreds of thousands of GitHub stars in weeks. "The end of jobs" headlines everywhere.
The reality? The agents wandered in circles, hallucinated their own subtasks, forgot what they were doing, and cheerfully burned through API credits like toddlers with a stolen credit card. Almost nothing useful was ever shipped by them.
And yet — 2023 mattered enormously:
Hype level: 100. Actual capability: 4.8. The gap between those two numbers is where the next three years happened.
Then the gap started closing — fast.
Devin (March 2024) marketed itself as "the first AI software engineer" and triggered equal parts hype and backlash. Cursor and its siblings moved the agent inside the editor, editing across your whole codebase instead of one line at a time. Reasoning models like o1 learned to think before answering. Anthropic shipped computer use — a model operating a screen, mouse and keyboard like a person — and then, in late 2024, something less flashy and more important: MCP, the Model Context Protocol.
MCP became the USB-C of AI — one open standard connecting any agent to any tool, database, or service. Within months, OpenAI, Google and Microsoft all adopted it. The agents could finally plug into the real world.
And then came the terminal agents — Claude Code, Codex CLI, Gemini CLI — agents that live where the real work happens: reading your codebase, writing, testing, fixing, committing, opening PRs. Andrej Karpathy coined "vibe coding" for the new workflow: describe what you want, watch it appear, never look at the code.
SWE-bench scores stopped crawling and started climbing vertically.
Which brings us to right now — and the numbers are honestly hard to believe:
If 2023 was the year of autocomplete and 2024–2025 the era of AI-powered IDEs, then 2026 is the year of agent engineering. You no longer ask the AI to finish a line. You delegate the ticket.
But there is a catch — and it's the most important sentence in this article: unreviewed AI code ships measurably more bugs and vulnerabilities than human code. The bottleneck has moved from writing software to verifying it. Which is exactly why the discipline I wrote about in Harness Engineering — designing the environment, the constraints, and the verification loops your agents live inside — is quickly becoming the most valuable skill in the industry.
Not because chatbots got smarter. Because the paradigm flipped: from AI that answers to AI that does.
Code went first for a simple, beautiful reason — it's verifiable. Tests pass or they don't. Programs compile or they don't. An agent can check its own work thousands of times per hour. But the same loop is now spreading outward: research agents that investigate for hours, office agents that operate spreadsheets and browsers, agents in law, science, and design.
Look at how long the thread really is. Turing asked whether machines could think. Winograd made one act. Minsky guessed the architecture. DeepMind proved they could learn. The Transformer gave them a mind, ReAct gave them hands — and now they build alongside us, every single day.
Seventy-five years to become an overnight success.
The machines have finally learned to do the work. Our job — the one that was never automatable — is to be worth listening to: to bring the intent, the taste, and the constraints that turn all that raw capability into something that matters.
The orchestra can play now. Time to learn how to conduct.
]]>If you have been paying attention to the AI coding space, you know we have moved past the era of stateless chatbots. We are now orchestrating stateful, autonomous coding agents capable of executing complex, multi-step workflows. But this rapid evolution brought a massive headache: standard proliferation.
Three months into using AI agents on a production codebase, you might find yourself correcting the same mistakes every session. Every tool wanted its own configuration file. Cursor wanted .cursorrules, Claude Code wanted CLAUDE.md, and GitHub Copilot wanted .github/copilot-instructions.md. Our repositories quickly turned into fragmented markdown museums for confused bots.
Fortunately, the industry woke up. Enter the .agents standard—a unified, cross-platform architecture backed by the Agentic AI Foundation and the Linux Foundation. Here is how it fundamentally changes how we build software with AI.
At the core of this new paradigm is a single file: AGENTS.md. You can think of it as a "README for machines". While your traditional README.md is optimized for human developers (quick starts, project descriptions), AGENTS.md is strictly optimized for your AI agent.
Located at the root of your repository, it acts as a high-level router. Instead of dumping your entire project's history into the LLM's context window—which obliterates its attention budget—AGENTS.md provides explicit, shallow instructions. It defines the agent's identity (e.g., "You are a Senior TypeScript Engineer"), outlines basic setup commands, and tells the agent exactly where to look for deeper context.
If AGENTS.md is the router, the .agents hidden folder is the database. Injecting massive product requirement documents and architecture guidelines into every prompt is a guaranteed way to pollute the context and induce AI hallucinations.
The .agents directory solves this using a psychological and computational principle called Progressive Disclosure. The agent is given a map of available knowledge, but it only loads specific files when the task demands it. A standard implementation looks like this:
.agents/rules/: Invariant behavioral guidelines, like strict coding standards..agents/wiki/: High-level domain and architecture guides..agents/personas/: Specialized profiles, allowing the agent to wear different "hats," like a QA or Security Engineer..agents/skills/: Reusable procedural workflows and capabilities.As you dive deeper into agentic architecture, you will inevitably hit a crossroads: should you build an Agent Skill or a Model Context Protocol (MCP) server? The best software creators know how to use both.
MCP (Model Context Protocol) is the "USB-C port for AI". It provides raw, structured technical capabilities, connecting your agent to external databases, Slack, Jira, or Google Drive via strict, OS-level process boundaries. MCP gives your agent the ability to do something, but it does not teach it why or how to do it according to your company's business logic.
Agent Skills (.agents/skills/) provide the missing reusable procedural knowledge. While an MCP server grants your agent the raw technical ability to query a database or access an API, it does not understand your specific business logic. An Agent Skill acts as a semantic training manual, teaching the agent the exact sequence of steps to perform a workflow—such as fetching data and formatting it into a standardized status update.
A skill is packaged as a folder containing optional helper scripts, reference documents, and a required SKILL.md file. This core file uses YAML frontmatter to establish its identity and define strict permission gates (like the allowed-tools parameter), followed by plain-text Markdown instructions.
Here is an example of what a SKILL.md file looks like for an automated standup generator:
---
name: weekly-standup
description: Analyzes git commit history to generate a formatted weekly standup report.
version: 1.2.0
allowed-tools: Bash(git:*) Read
---
# Instructions
1. Execute `scripts/fetch-commits.sh` to retrieve the user's git log for the past 7 days.
2. Read `references/standup-template.md` to understand the required markdown output format.
3. Categorize the raw commits into "Features," "Bug Fixes," and "Chores."
4. Output the final markdown report directly to the user.
By combining structured MCPs for technical reach and Agent Skills for step-by-step reasoning, you give your AI both the power to act and the wisdom to execute tasks correctly according to your team's conventions.
The barrier to entry for setting up this architecture is incredibly low today. You no longer have to build these folders manually. Using the dotagents CLI tool, you can instantly scaffold a compliant architecture in any repository.
Just run npx @sentry/dotagents init to create your agents.toml manifest and .agents/skills/ directory, and you can start adding capabilities directly from open-source repositories. Because different IDEs still look in different namespaces (like .claude/ or .github/), the CLI automatically handles symlinking, ensuring your .agents folder remains the single source of truth across all platforms.
The gap between developers who copy-paste prompts and those who engineer robust agentic systems is widening rapidly. Stop treating your AI like a stateless chatbot. Give it a memory, give it skills, and let it work.
]]>
If you think Stoicism is about suppressing your emotions and being a feelingless robot, you're dead wrong. This is arguably the most practical philosophy ever created. A philosophy born not in quiet academic halls, but out of chaos, shipwrecks, and political tyranny.
Here is everything you need to know about Stoicism to get started, filtered through the lens of modern life. No academic fluff. Just what works.
Picture this: you lose your entire business, all your wealth, and find yourself penniless in a foreign city. That's exactly what happened to Zeno — a Phoenician merchant whose ship sank. Instead of giving in to despair, he discovered philosophy in Athens and started teaching on a painted public porch (in Greek, Stoa — hence "Stoicism").
The key lesson? You can't control the shipwreck. You only control what you do after it.
The early Stoics had a brilliant metaphor: You are like a dog tied to a moving cart. The cart (life) is going wherever it wants. Your choice is simple — you can trot cheerfully alongside it, or you can lie down and get dragged. But the cart is moving either way.
The Stoics believed that a good life rests on four virtues. They are independent but work in sync.
While the Greeks were the theorists, the Romans battle-tested Stoicism in real life. And by "real life," we mean running empires, enduring slavery, and surviving under crazy tyrants.
How do you apply all this today? Here are a few tools — tested by centuries — that beat any modern "life hack" trend.
If you only remember one thing from this guide, let it be this:
You don't control what happens to you. You only control how you respond to it.
The harder and messier the situation, the greater the opportunity to show character. Stoicism isn't a book you read once and put on a shelf. It's a daily practice. Every day you wake up and start over.
As Marcus Aurelius told himself:
Fight to be the person philosophy tried to make you.
]]>In recent years, something fundamental shifted in how we build software. We transitioned from the era of shy "copilot" assistants waiting for our approval on every line of code, to the era of always-on, autonomous agents.
Paradoxically, the faster these systems generate code, the faster experienced engineers burn out. We fall into the trap of "cheap dopamine"— the AI spits out a working feature in minutes, our brain celebrates the quick win, but during the architectural review, we realize we've built a chaotic house of cards that must be entirely rewritten.
To survive and thrive in this new reality, we have to stop competing with machines on typing speed. We must shift our role.
Before we dive into how we engineer these systems, we need to address the philosophical elephant in the room. Artificial Intelligence is merely an enhancer of our own human skills.
Think of it this way: until now, we have been digging with shovels. Suddenly, someone handed us the keys to an excavator. If you know how to operate it, you can build a skyscraper. If you don't, you can easily demolish the whole neighborhood. AI amplifies what you already have—it can make you exponentially better, but it can also make your output exponentially worse if you lack direction.
Because of this, three things will never be replaced by AI:
AI is the executor. We are the visionaries. The evolution of how we guide this executor happens in three distinct stages.
This was the dawn of AI coding. The entire focus was on how to ask the "perfect" question to get the perfect response in a single session.
The problem? Large Language Models (LLMs) are stateless. The more you force them to solve complex, multi-file architectural problems via one massive prompt, the more "slop" they generate. Writing massive prompts to build an entire app in one shot turned us into micromanagers of machines with zero short-term memory.
When we realized prompts weren't enough, we moved to context management. Here, the goal isn't the length of the instruction, but its purity. If you dump entire files, test logs, and JSON outputs into a chat window, you enter the "Dumb Zone." The solution is intentional context compaction through the RPI (Research, Plan, Implement) method:
This is the future and the highest level of AI programming today. A Harness Engineer doesn't just manage the context for a single chat session. They design the system architecture where autonomous AI agents live, work, and pass the baton over long-term, complex tasks.
Harness Engineering is built on three foundational principles:
progress.txt and a central agents.md) so that any new agent entering the workspace instantly knows what is finished and what the priorities are.grep, npm run) infinitely better than a highly specific, custom JSON tool you built yesterday, providing these foundational tools allows smart AI agents to dynamically build their own custom tools on demand.With this incredible new power of Harness Engineering and Dark Factories comes a corresponding, and much less celebrated, responsibility. As the hierarchy of error leverage shows us, AI is an enhancer, not just of positive human skill, but of every single input. Mistakes at the top of the pipeline do not just scale linearly; they are amplified a hundred, a thousand, or even a hundred thousand times.
Consider the conceptual model of a "Hierarchy of Error Leverage." A single line of bad code might result in a single bad line. This is the shovel work we are used to.
But move up the hierarchy of logic, and everything changes.
This amplification cascade is the hidden danger of the Dark Factory. When you automate the bricklaying, you must ensure the blueprints—your specification, your taste, and your intent—are absolutely perfect. The AI will build exactly what you tell it to, but it will not fix a flawed specification. If we ship with "vibe coding" specification, we will not just get a few bugs; we will receive a structurally compromised software asset. We must operate with the foresight of a civil engineer, not just a casual observer. We must become the ultimate validators of our high-taste commands and specifications.
We are entering the phase of the "Dark Factory"—a highly autonomous system where humans rarely write or review standard syntax. The specification goes in, and working software comes out.
This does not make the software engineer obsolete; it elevates them. Your true value is no longer in writing syntax (shallow work), but in deep work: systemic thinking, defining clear interfaces (Deep Modules), and writing unambiguous PRDs that serve as meta-prompts for your virtual team.
You are no longer the bricklayer. You are the Radical Generalist. You are the conductor of an orchestra, using your taste, intent, and constraints to turn pure ideas into reality.
As long as you keep creating and giving to the world, your presence will always matter.
]]>If you lived your life entirely through push notifications in 2025, you probably think the world is crumbling. Bad news travels fast – it keeps you clicking. But if you look at the hard facts and real numbers, a different picture appears.
While the world was distracted by noise, 2025 was quietly one of the most important years for human progress. We broke barriers in genetics, stopped relying so much on coal, and even got rival nations to sign peace treaties.
Here are 10 real reasons to be optimistic about where we are heading, based on the science and data of the last 12 months.
For decades, a genetic diagnosis for rare diseases was often a death sentence. In 2025, it became a solvable engineering problem. At the Children’s Hospital of Philadelphia, doctors used a custom-made gene-editing therapy to cure an infant of a fatal metabolic disorder called CPS1 deficiency.
This wasn't a normal drug trial. They mapped the baby's DNA, built a cure just for him, and treated him within six months. The child, who would have previously faced severe brain damage, is now thriving. We have officially entered the era where we can "program" cures for individual people.
The mRNA technology that saved us during the pandemic has found a new job: fighting cancer. In 2025, results from Memorial Sloan Kettering showed that a personalized mRNA vaccine for pancreatic cancer – one of the deadliest kinds – kept 75% of patients cancer-free three years later.
Perhaps even more surprising? Researchers at MD Anderson discovered that standard COVID-19 vaccines actually prime the immune system to fight cancer better, doubling the survival rate for certain patients on immunotherapy.
The old argument that "developing nations need coal to grow" died in 2025. India, the world's most populous nation, saw its coal capacity drop below 50% of its total energy mix for the first time in history.
Why? Money. It is now cheaper to build huge solar farms than to burn coal. Meanwhile, China is projected to have installed nearly 70% of the world's wind power this year, effectively peaking its emissions years ahead of schedule. Going green is no longer just about charity; it's about smart business.

On June 23, 2025, the Vera C. Rubin Observatory in Chile captured its First Light images. This isn't just another telescope; it's a massive 3.2-gigapixel camera that will photograph the entire southern sky every few days for a decade.
The result will be a "time-lapse movie" of the universe, cataloging 20 billion galaxies and mapping the dark matter that holds reality together. We are moving from static snapshots of space to a real-time streaming view.

For centuries, the ocean beyond national borders (50% of the planet) was like the Wild West. In September 2025, the High Seas Treaty finally got enough signatures to become law.
This allows us to create massive protected areas in the middle of the ocean, which is critical to protecting marine life. Nature, it seems, is also collaborating: 2025 saw the first confirmed scientific proof of orcas and dolphins working together to hunt, showing that cooperation is a winning strategy for survival.

We stopped talking about "Quantum Supremacy" (doing useless things fast) and started seeing "Quantum Utility." Google's Quantum AI team revealed Quantum Echoes, a breakthrough that allows quantum computers to do calculations for chemistry that are actually useful for science.
At the same time, the release of AlphaFold 3 allowed us to predict the structure of all of life's molecules – DNA, RNA, and proteins – compressing years of lab work into minutes of digital simulation.
In a massive win for public health, the World Health Organization confirmed that global polio cases have dropped by 99% over the last 35 years. Regions like South-East Asia celebrated over a decade of being polio-free, proving that when the world works together on vaccinations, we can wipe out diseases.
Despite the tension in the headlines, 2025 saw the end of some very old conflicts. Armenia and Azerbaijan signed a historic peace agreement, normalizing relations after 30 years of fighting. Similarly, Thailand and Cambodia signed a ceasefire agreement in December to end border skirmishes, proving that diplomacy is still alive.
It’s a small upgrade, but for billions, it’s magic. The FDA approved VIZZ eye drops, a daily drop that corrects age-related vision loss. It works by shrinking the pupil to create a "pinhole camera" effect, restoring your ability to read up close without needing surgery or reading glasses.
Finally, proof that we can fix the planet. NASA confirmed that the Antarctic ozone hole shrank to its fifth-smallest size in three decades. This is the direct result of the global ban on certain chemicals in the 1980s. It took a generation, but we identified a threat, agreed on a solution, and the planet responded.
The Takeaway:
Progress isn't a straight line, and it rarely makes the front page. But 2025 proved that when we use science, engineering, and teamwork to solve our problems, we don't just survive – we upgrade.
Here is to keeping the momentum in 2026.
]]>Fasting is often reduced to a simple conversation about weight loss, but viewing it solely through that lens misses the bigger picture. When you stop eating for a prolonged period, you aren't just cutting calories; you are flipping a metabolic switch that activates ancient, dormant survival mechanisms.
For the last few weeks, I’ve been diving deep into the chronobiology of fasting—specifically the profound changes that occur during a 72-hour window. The science is fascinating. From sky-rocketing growth hormone levels to the regeneration of immune stem cells, a 72-hour fast is less about "starving" and more about cellular "pruning" and renewal.
To help you visualize and track these invisible milestones, I’ve also built a new tool: the Fasting Planner. But first, let’s look at the data to understand why you might want to fast in the first place.
Fasting isn't a static state; it's a dynamic journey through distinct physiological stages. Here is the breakdown of what is happening under the hood.
Understanding these stages is one thing; tracking them in real-time is another. I realized that most fasting apps are either too cluttered with ads or lack the granular data I wanted to see. I needed a tool that was clean, easy to use, and visually intuitive.
So, I built Fasting Planner.

It is a dedicated tool designed to help you architect your fasting protocols with precision.
Whether you are attempting your first 16:8 intermittent fast or preparing for a therapeutic 72-hour reset, having a visual roadmap makes the discipline much easier to maintain.
Check it out here: fasting-planner.harduex.com
Disclaimer: Fasting for 72 hours is a significant physiological stressor. Always consult with a medical professional before undertaking prolonged fasting, especially if you have underlying health conditions.
]]>Ever wondered how Apashe crafts those massive, cinematic bangers?
This article is your backstage pass to the mind of the Montreal-based maestro himself.
Whether you're an aspiring producer, a genre-bending DJ, or just a music nerd—this one's for you.
Apashe doesn't just sample strings—he hires a whole orchestra.
For his album Renaissance, he recorded a 65-piece orchestra in Prague. For Antagonist, he went even bigger: the Bulgarian Symphony Orchestra + a children’s choir!
His trick?
Start with MIDI demos using tools like Kontakt and Orchestral Tools → Send them to a pro orchestrator → Record live → Chop, remix, and flip your own sounds like a DJ.
"It's kind of like remixing my own compositions."
Pro tip: Can’t hire an orchestra? Layer strings from Kontakt, blend with cinematic brass, and get creative with resampling.
Apashe learned sound design the old-school way—messing around for hours.
Forget one-size-fits-all tutorials. He dove deep into DogsOnAcid forum, dissected plugins, and experimented until sounds clicked.
Example: That fat bassline in "No Twerk"?
Not a synth. It's over-processed horns—EQed, saturated, and compressed into oblivion.
"There are no magic tricks... it's trial and error."
Try this:
Experiment until you surprise yourself.
Forget endless back-and-forth between DAWs.
Apashe mixes as he composes—all inside Ableton Live.
He believes in staying in the moment:
"If a demo still gives you chills after six months, it’s worth finishing."
Here’s a peek into Apashe’s studio:
🎛️ DAW: Ableton Live
🎛️ Orchestral Mockups: Kontakt, Orchestral Tools
🎛️ Sound Design: Melodyne, bx_subsynth, iZotope, Waves, Melda Production
🎛️ Monitoring: Neumann Speakers
🎛️ Hardware: Access Virus C, Korg Electribe, Push
🎛️ Vocal Processing: EQ, Compression, Old Reverbs, and Delays
Apashe’s golden rule?
Make music because you love it. Fame and gigs? That’s extra.
"When I made music to chase bookings, it never worked. When I did it for fun, that's when things clicked."
Don't overthink it. Try new ideas. Blend genres. Create something you love.
✅ Keep it fresh: Step away from your track, return later
✅ Layer real instruments: Orchestras + synths = fire
✅ Test new tools: Don't fear plugins, but don't chase FOMO
✅ Chop your own recordings: Remix yourself
✅ Mix as you go: Don’t save it all for the end
✅ Focus on the vibe: Technicals matter, but emotion drives the track
✅ Have fun: It’s a creative playground, not a grind
Apashe’s approach is simple yet powerful:
Now, it’s your turn.
Open your DAW. Mess around. Get weird. Push the limits.
Maybe one day, your tracks will land in a movie trailer too. 🎬

Ever wondered how KOAN Sound creates those mind-bending, hyper-detailed tracks that somehow feel both mechanical and alive?
Let’s dive into the minds of Will Weeks and Jim Bastow (aka KOAN Sound) and pull together their most eye-opening production tips - no fluff, just real insights you can actually use.
"Everything is possible... You can’t do something wrong."
— KOAN Sound
KOAN Sound’s #1 rule? Forget the rules.
Music isn’t about formulas — it’s about fun and experimentation. Don’t get stuck wondering if you're "doing it right." Start throwing sounds around and play with ideas.
Pro Tip: Their best ideas come when they turn off the analytical brain. No second guessing. Just flow.
They describe entering a “meditative state” where time disappears and ideas just happen. That’s the sweet spot. No overthinking, no pressure.
Try this: Dim the lights. Turn off your phone. Loop a sound you love and zone in.
"Learn ONE technique and go deep."
KOAN Sound doesn't chase the latest plugin. Instead, they dive deep into a few VSTs, squeezing every drop of creativity from them.
Pro Tip: Focus on what your current tools can really do before buying the next thing.
From plastic bottles crunching to footsteps in snow, KOAN Sound layers in foley and live instruments for textures that feel real.
In "The Zulla", they built percussion using creaky floorboards.
In "Drift", they used a Koshi wind chime.
They resample their own basses and instruments repeatedly. This adds grime, texture, and unpredictability.
Technique Highlight: Moist Neuro Bass
Tip: Automate volume per band - especially the high end - for motion and character.
Their snares often blend:
They’ve even used Ableton’s vocoder to compress snares and add a “slightly synthetic” character.
Each percussive hit is treated like a musical phrase. Ghost notes, swing, and shuffle give their tracks that bounce.
Plugins they love:
“The most powerful sound shaping tool” — KOAN Sound
Learn to:
This applies to every layer, not just the bass.
Using effect racks with wet/dry chains lets you:
Ableton Hack: Build an FX rack template once, use it everywhere.
Always listen in mono to make sure your stereo spread doesn’t kill clarity.
“What sounds amazing wide should also sound good dead center.”
Utility audio effect on the master chain makes this a breeze.
Usually the drums. Sometimes the vocal. Identify it early, and build the rest of the mix around it.
Hot tip: A punchy kick needs space. Don’t let your sub or synths crowd it.
“Exercise is sooo important for a sedentary profession.”
Physical and mental health directly fuel their motivation and creativity. Go for a walk. Hit the gym. Stretch between takes.
They didn’t try to sound unique — they just made what felt natural.
“If something sounds like you, then no one can take that away from you.”
Consistency + curiosity = originality.
Want to sound more like KOAN Sound? Don’t try to copy them.
Instead:
Open your DAW and build a track using:
Drop a comment with your favorite KOAN-inspired technique or mention this article in your next weird sound experiment!
Let the chaos flow. 🎛🔥
Your masterpiece is one weird sound away.
Ever wondered how Boris Brejcha creates those hypnotic, high-energy tracks that destroy the clubs around the world?
Good news—you don’t need a million-dollar studio or a shelf full of analog gear to get close. Boris is all about speed, feel, and authenticity in the studio. And in this post, we’re breaking down his most actionable music production tips—straight from interviews and behind-the-scenes peeks into his process.
Let’s dive in.
Boris doesn’t overthink. He doesn’t sketch out a full arrangement or plan 10 layers ahead. Instead:
“I just jam around in the studio… if something cool comes up, I go from there.”
Takeaway: Open your DAW and start messing around. If something clicks, run with it. If not — move on.
Photo by Techivation / Unsplash
Time kills creativity. That’s why Boris moves fast.
If a project doesn’t take off quickly? Delete it. Seriously.
“Unfinished projects block your mind.”
Try it: Give yourself a 48-hour finish challenge. You’ll be shocked how much better your music flows.
Boris uses Cubase because he’s used it forever. It’s not about what’s trendy—it’s about what’s fast for you.
“It’s about knowing your tools inside out. That’s what makes you fast.”
He works in the box using software synths and plugins — Omnisphere, Trilian, Alchemy, Nexus, Massive, Fabfilter, and a hidden gem called “One” (cheap but killer for bass).
Photo by Techivation / Unsplash
This one’s important: fewer tracks, more automation.
“Sometimes, it’s better to delete a sound than add another one.”
Instead of stacking 40 layers, Boris focuses on movement — automating knobs, filters, effects to make each sound come alive. We also saw this with Skrillex in my previous article — he’s all about using automation to add life and variation, rather than piling on more layers.
Pro tip: Automate everything. Envelopes, filters, LFOs, even plugin dry/wet knobs.
Mixing advice from Boris: almost no compression.
“Compressors destroy too much of the sound.”
Instead, he EQs carefully and uses a Hofa plugin to tame peaks by cutting certain frequencies — only when needed.
Photo by Caught In Joy / Unsplash
This makes the mix clean, dynamic, and punchy without the squash.
Mechanical drums kill groove. Instead of locked 1/16 notes, Boris uses tiny timing shifts (like 1/64) to get that natural, swingy flow that dancers feel in their bones.
“That groove is what makes people move.”
Photo by Marcela Laskoski / Unsplash
Almost every Boris track uses white noise — especially for transitions or after breakdowns. Simple, powerful, effective.
Try this: Layer white noise with a filter sweep before your drop and hear the difference.
Some of Boris’s best sounds came from doing something “wrong”—like stacking plugins in weird ways or hitting the wrong note.
“Mistakes in the studio can become the heart of a track.”
So next time something unexpected happens? Don’t delete it—use it.
This is the big one. Boris constantly stresses this:
“If you stand 100% behind your sound, fans will feel it—and love it.”

Becoming a producer like Boris takes time. It’s not a 9-5. It’s late nights, trial and error, gigs, flops, and breakthroughs.
“It takes years. But it’s worth it.”
Stay consistent. Stay weird. Stay true.
Quick Reference Checklist

Boris Brejcha’s music feels alive and unique — and that’s no accident. It’s a result of smart workflows, fast decisions, and staying deeply connected to what feels right instead of what looks right.
If you’re looking to level up your music production, you don’t need to copy his sound. Just adopt his mindset.
Create. Delete. Play. Repeat.
Enjoyed this breakdown?
Drop a comment with your favorite Boris track and don’t forget to share these tips with a fellow producer!
Be creative!
]]>Ever wondered how electronic music giants like Skrillex approach their craft? It turns out, it's not always about complex setups or secret plugins. Drawing insights from curated conversations and interviews about his creative process, we uncover some fascinating and surprisingly simple tips from Skrillex himself.
Here are some key takeaways for anyone looking to enhance their music production workflow — straight from Skrillex:

Often, the initial idea for a track comes as a simple melody or feeling. Skrillex emphasizes starting with this basic concept — a skeleton version of the track. He mentions having a melody in his head and building around it with elements like a counter-melody and a simple bassline.
“The sounds themselves might not even be that interesting at this stage; the crucial part is getting the core idea down.”
Contrary to popular belief, many of his sounds end up being really simple. For example, he’s used dreamy, vibey textures made from just a Vengeance sample with a little glide and reverb. The real magic, he says, often happens later when processing the bounced audio.

Skrillex’s workflow thrives on speed and iteration. He often spends an hour on a basic idea, saves it, then moves on to several others. Later, he revisits them with “a fresh brain, a fresh ear.”
This strategy boosts creativity and enables more objective evaluation of which ideas are worth developing.
Photo by Håkon Grimstad / Unsplash
When revisiting his ideas, Skrillex is flexible. Love the sound but not the melody? Switch it up. The ability to pivot based on what works best in the moment is key to evolving a track.

Travel is "absolutely crucial" to Skrillex’s creativity. He draws inspiration from international sounds, stating:
“My whole sound is international sounds synthesized through my own brain and mind.”
Exploration and failure are both vital parts of learning — and they help shape his ever-evolving sound.

Skrillex finds sounds in the most unconventional places — cracking soda cans for snares, recording vocals on an iPhone. His philosophy? Use what you’ve got.
This approach champions resourcefulness and creativity over gear obsession.

While he keeps up with the latest tools and trends (including AI), Skrillex insists that ideas come first:
“Ideas, an aesthetic, and a concept are bigger than any tool.”
More accessible tools mean more people worldwide can now make music. That's a good thing.
Inspired by mentor Martin Dodd, Skrillex follows a powerful principle:
“You exchange wisdom for energy.”
He believes in giving away good ideas. The world needs more of them — so don’t hoard what you’ve learned. Share freely.
Photo by Techivation / Unsplash
When asked about his favorite plugins, Skrillex keeps it minimal:
Powerful tools don’t have to be exotic — often, they’re already in your DAW.

Skrillex uses automation to create movement and emotion. For instance, he automates:
He likens the evolution of a track to a story:
“A baby beat that is shy but gains confidence and strength over time.”
Automation breathes life into electronic music — and tells a story within the sound.
Skrillex’s approach isn’t about complicated gear or elite techniques — it’s about ideas, energy, simplicity, and exploration. Start with what inspires you, keep it simple, work fast, stay open to change, and use technology as a means to a creative end.

If you’ve ever scrambled to find missing samples, struggled with transferring your project to a new computer, or had trouble sending it to another producer for collaboration, you’re not alone. Fortunately, Ableton Live offers a neat feature called Collect All and Save, which gathers everything you need into one tidy folder. Let’s break down the process and explore a few tips for seamless collaboration.
Keeping all your samples, audio files, Max for Live devices, and configurations in one dedicated folder prevents missing assets when moving projects between computers. However, note that while Collect All and Save will copy your audio and device files, it does not include plug-ins. If your project uses third-party plug-ins, consider freezing and flattening those tracks (unless the target machine already has the same plug-ins installed). This step is especially important when transferring projects across different operating systems since only VST and VST3 formats are cross-platform, while Audio Units (AU) work only on macOS.
Open Your Ableton Live Set
Launch your project in Ableton Live. Ensure all your tracks and settings are as you need them.
Save as a New Project Folder
Go to File > Save Live Set As and choose a new location outside any existing project folders. This creates a dedicated folder for your project and keeps it organized.
Collect All and Save
Click File > Collect All and Save. In the dialogue window, enable all options. This copies all used audio files and Max for Live devices into your project folder. Remember, plug-ins aren’t collected, so if necessary, freeze and flatten tracks that rely on them.
Prepare for Transfer
Locate your project folder, compress it (e.g., ZIP it), and transfer it to your collaborator or new computer. If you’re transferring to a different system (e.g., Windows to Mac), ensure you have compatible plug-in formats or have frozen tracks containing AU plug-ins.
By creating self-contained bundles, you ensure that every asset you need is in one place. This method prevents missing files, eases project transfers, and streamlines collaboration. Just follow the steps, and you'll have a hassle-free project ready for sharing or moving to another computer.
Happy producing!
]]>In this tutorial, we’ll build a simple but powerful React application to manage user preferences (such as theme and language) using React Context and TypeScript. Even if you’re new to React Context, by the end you’ll understand how it works, why it’s useful, and how to implement it in a type-safe manner.
Imagine you’re building an application where users can toggle between a light and dark theme and switch languages. How can you manage this state across many components without passing props down through every layer? React Context is the answer. However, if you’re not familiar with Context or TypeScript, things might seem daunting. Don’t worry! We’ll break it down.
We’ll start with creating React app using the Vite TypeScript template. Follow these steps to set up your project:
Create the Project:
Open your terminal and run:
npm create vite@latest my-app -- --template react-ts
cd my-app
npm installProject Structure:
After setting up, your file structure should look similar to this:
my-app/
├── package.json
├── tsconfig.json
├── vite.config.ts
└── src/
├── main.tsx
├── App.tsx
├── contexts/
│ └── UserPreferences.tsx
└── components/
└── ThemeToggle.tsx
We’ll add our new files (contexts/UserPreferences.tsx, and components/ThemeToggle.tsx) into the src folder.
First, let’s build our context. This is where we encapsulate our state and its update logic. Create a new file called src/contexts/UserPreferences.tsx:
// src/contexts/UserPreferences.tsx
import { createContext, PropsWithChildren, useContext, useMemo, useState } from 'react';
// Defining our types
interface UserPreferences {
theme: 'light' | 'dark';
language: 'en' | 'es' | 'fr';
}
interface UserPreferencesContextData extends UserPreferences {
setTheme: (theme: UserPreferences['theme']) => void;
setLanguage: (language: UserPreferences['language']) => void;
}
interface ProviderProps {
initialPreferences?: Partial<UserPreferences>;
}
// Create our Context object with an initial null value.
const UserPreferencesContext = createContext<UserPreferencesContextData | null>(null);
// Helpful display name for debugging
UserPreferencesContext.displayName = 'UserPreferencesContext';
// A custom hook that initializes and returns our context state
function useCreateUserPreferences({
initialPreferences = {},
}: ProviderProps): UserPreferencesContextData {
const [theme, setTheme] = useState<UserPreferences['theme']>(
initialPreferences.theme ?? 'light'
);
const [language, setLanguage] = useState<UserPreferences['language']>(
initialPreferences.language ?? 'en'
);
// We use useMemo to prevent unnecessary re-renders.
return useMemo(
() => ({
theme,
language,
setTheme,
setLanguage,
}),
[theme, language]
);
}
// Provider component that wraps your app and makes the context available
export function UserPreferencesProvider({ children, ...props }: PropsWithChildren<ProviderProps>) {
const preferences = useCreateUserPreferences(props);
return (
<UserPreferencesContext.Provider value={preferences}>
{children}
</UserPreferencesContext.Provider>
);
}
// Custom hook to use our context in any component
export function useUserPreferences() {
const context = useContext(UserPreferencesContext);
if (!context) {
throw new Error('useUserPreferences must be used within a UserPreferencesProvider');
}
return context;
}Creating the Context:
We initialize the context with a null default. This forces consumers to use our provider so they always get the correct data.
Provider Component:UserPreferencesProvider wraps your components and supplies them with our state. The custom hook useCreateUserPreferences sets up the initial state and returns the state along with the updater functions.
Custom Hook (useUserPreferences):
This hook lets any component access the context. It also provides a helpful error if you forget to wrap your component tree in the provider.
Let’s create a simple component that toggles the theme. Create src/components/ThemeToggle.tsx:
// src/contexts/ThemeToggle.tsx
import { useCallback } from 'react';
import { useUserPreferences } from '../contexts/UserPreferences';
export function ThemeToggle() {
const { theme, setTheme } = useUserPreferences();
const toggleTheme = useCallback(() => {
setTheme(theme === 'light' ? 'dark' : 'light');
}, [theme, setTheme]);
return <button onClick={toggleTheme}>Toggle theme (Current: {theme})</button>;
}
Here, our ThemeToggle component uses the custom hook to get the current theme and the function to update it. When clicked, it toggles between "light" and "dark".
Finally, we need to integrate our provider into the application. Update your main src/App.tsx file as follows:
// src/App.tsx
import { UserPreferencesProvider } from './contexts/UserPreferences';
import { ThemeToggle } from './components/ThemeToggle';
function App() {
return (
<UserPreferencesProvider initialPreferences={{ theme: 'dark' }}>
<div style={{ padding: '2rem' }}>
<h1>Type-Safe React Context Example</h1>
<ThemeToggle />
</div>
</UserPreferencesProvider>
);
}
export default App;With everything in place, start your development server:
npm run dev
Open http://localhost:5173 (or the URL provided in your terminal) in your browser. You should see a page with a button that toggles the theme. The current theme is displayed on the button itself!
Type Safety:
By defining our types, we ensure that any misuse of the context is caught at compile time. This helps prevent bugs and improves the developer experience.
Encapsulation:
The logic to manage state is isolated within a custom hook (useCreateUserPreferences) and a provider. This separation makes our code easier to test and maintain.
Performance:
Using useMemo ensures that the context values only update when necessary, reducing unnecessary re-renders in our components.
Developer Experience:
Clear error messages (like when useUserPreferences is used outside its provider) and a discoverable API make this pattern pleasant to work with.
In this tutorial, we walked through the process of creating a type-safe React Context to manage user preferences using Vite and TypeScript. We started by setting up the project with Vite, defined our types, built our context provider and custom hook, and finally integrated everything into a simple React app. This pattern not only makes your state management robust but also improves performance and developer experience.
By following this approach, you can scale your application and keep your state logic clean and well-organized. Happy coding!
Feel free to experiment and expand on this pattern—perhaps add more user preferences or split context domains as your application grows. Enjoy your journey into type-safe React Context!
]]>