Agent skill
data-layer
This skill provides patterns for working with the data-layer module. Use when creating/editing files in src/data-layer/, src/lib/data/, or adding new data sources.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/data-layer-ethereum-ethereum-org-website
SKILL.md
Data Layer
Architecture
src/data-layer/ # Isolated, framework-agnostic module
├── api/ # Fetch functions (one per data source)
├── index.ts # Getter functions (pure passthrough)
└── registry.ts # Task registry (hourly/daily)
src/lib/data/ # Next.js caching adapter
└── index.ts # Cached wrappers via createCachedGetter()
Rules
1. Getters must be pure passthrough
In src/data-layer/index.ts, getter functions must only call getData<T>(TASK_ID) with no transformations:
// Correct
export async function getEventsData(): Promise<EventItem[] | null> {
return getData<EventItem[]>(FETCH_EVENTS_TASK_ID)
}
// Wrong - no transformations in getters
export async function getEventsData(): Promise<EventItem[] | null> {
const data = await getData<EventItem[]>(FETCH_EVENTS_TASK_ID)
return data?.map((e) => ({ ...e, computed: derive(e) })) ?? null
}
All transformations belong in the fetch task (src/data-layer/api/), not in the getter.
2. Expose via lib/data for caching
When a data function needs caching/revalidation, add a cached wrapper in src/lib/data/index.ts:
export const getEventsData = createCachedGetter(
dataLayer.getEventsData,
["events-data"],
CACHE_REVALIDATE_DAY // or CACHE_REVALIDATE_HOUR
)
Adding a New Data Source
-
Create fetch function in
src/data-layer/api/fetchNewData.ts:typescriptexport const FETCH_NEW_DATA_TASK_ID = "fetch-new-data" export async function fetchNewData(): Promise<YourDataType> { // Fetch and transform data here } -
Add getter in
src/data-layer/index.ts:typescriptexport async function getNewData(): Promise<YourDataType | null> { return getData<YourDataType>(FETCH_NEW_DATA_TASK_ID) } -
Register in
src/data-layer/registry.ts(hourlyTasks or dailyTasks) -
Add cached wrapper in
src/lib/data/index.ts:typescriptexport const getNewData = createCachedGetter( dataLayer.getNewData, ["new-data"], CACHE_REVALIDATE_HOUR )
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?