context

Define and evolve stateful context logic in _.context.ts files with enforced unit tests.

169|19|Updated Apr 8, 2022
One-click install
npx skills add https://github.com/counterfact/api-simulator --skill context-counterfact
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: context
Source: https://github.com/counterfact/api-simulator/tree/main/skills/context
Command: npx skills add https://github.com/counterfact/api-simulator --skill context-counterfact

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Manage and evolve stateful business logic across Counterfact routes using _.context.ts, with enforced unit test coverage.

Core Features & Use Cases

  • Encapsulates domain actions and route state in _.context.ts files to centralize logic.
  • Keeps route handlers lean by delegating core rules to the context layer.
  • Enables consistent testing and evolution of context behavior across the application.

Quick Start

Update or add methods in routes/**/_.context.ts and run unit tests to validate changes.

Frequently Asked Questions about context

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage stateful context logic for Counterfact routes in TypeScript?

Stateful context logic for Counterfact routes is managed by encapsulating domain actions and route state in _.context.ts files. This centralizes business rules so route handlers stay lean and delegate core logic to the context layer.

What's the best way to keep route handlers lean while evolving state management?

The best way to keep route handlers lean is to delegate core rules to a context layer using _.context.ts files. By centralizing state management there, handlers avoid bloating and logic evolves consistently across the application.

How do I add unit tests for context behavior changes in TypeScript routes?

Unit tests for context behavior changes are added by updating methods in routes/**/_.context.ts and running the test suite. This enforces test coverage for every change, validating that context logic behaves as expected.

Can I centralize route state and expose a clear API using a context layer?

Yes, you can centralize route state and expose a clear API by defining actions within _.context.ts files. This approach maintains private state internally while providing a structured API for route handlers to consume.

How does _.context.ts work for managing domain actions across route subtrees?

The _.context.ts file works by applying stateful context logic to any route subtree within Counterfact. It encapsulates domain actions so that state and behavior are shared and tested consistently across nested routes.

Why do my route handlers keep growing with business logic instead of staying clean?

Route handlers grow with business logic when state management is not separated into a context layer. Moving core rules into _.context.ts files centralizes the logic, keeping handlers focused on routing concerns.