Data store
Skill Randomguy01/claudekit/plugins/androidx-data-store/skills/data-store
Store small amounts of data on Android with Jetpack DataStore. Use this skill when the user persists key-value pairs or typed objects locally on Android — saving user settings or app preferences, replacing SharedPreferences, reading and writing values as a Kotlin Flow, defining Preferences/Proto/JSON DataStores, wiring a serializer, accessing a store across processes, or handling file corruption. Applies even when the user doesn't say "DataStore" by name — e.g. "save the user's settings on Android," "store a toggle that survives restarts," "migrate off SharedPreferences," or "persist app config as a Flow." Skip for large, relational, or partially-updated datasets (use Room instead), and for non-Android or server-side storage.From its SKILL.md
npx -y skills add Randomguy01/claudekit --skill data-storeAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
6.5 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it
DataStore
Jetpack DataStore stores key-value pairs or typed objects on disk using Kotlin coroutines and Flow. Its API is two operations: read through a Flow<T> exposed by DataStore.data, and update transactionally with the updateData suspend function.
[!TIP] If the data is large, relational, partially updated, or needs referential integrity, use Room instead — DataStore is for small datasets and has no partial updates.
This skill is a router. Decide what the task needs, then read the matching file before writing or reviewing code. Task workflows (define → create → read → write) live in references/; the exact contract of any single type — constructor arguments, function signatures, properties — lives in api/. Open the reference guide for the task, then drill into the api/ file for any type it links.
Use DataStore Correctly
These rules apply to every task — keep them in mind regardless of which reference you open:
- One
DataStoreper file per process. Creating a second instance for the same file in the same process breaks DataStore — it throwsIllegalStateExceptionon reads and updates. Declaring the delegate at the top level of a Kotlin file enforces this. - The generic type
Tmust be immutable. Mutating a type stored in aDataStore<T>invalidates DataStore's consistency guarantees and causes hard-to-catch bugs. Proto types help enforce immutability. - Do not mix
SingleProcessDataStoreandMultiProcessDataStorefor the same file. To access a file from more than one process, use the multi-process construction everywhere — seereferences/multiprocess.md.
Choose a Configuration
DataStore comes in two configurations. Pick first, then open the matching reference for the full define → create → read → write lifecycle:
[!TIP] Use Preferences for simple key-value data with no schema. Use a typed DataStore to persist a custom class — Proto for a schema-enforced, immutable type (recommended), or JSON when you prefer kotlinx.serialization over Protocol Buffers.
- Key-value pairs,
SharedPreferences-style →references/preferences-datastore.md - Typed object serialized with Protocol Buffers →
references/proto-datastore.md - Typed object serialized with kotlinx.serialization JSON →
references/json-datastore.md
Reference Guides (references/)
Setup
- Add DataStore to a project (dependencies, serialization plugins) →
references/install.md
Using DataStore
- Consume a store from Compose (ViewModel,
collectAsStateWithLifecycle) →references/compose.md - Access a store from more than one process →
references/multiprocess.md - Recover from a corrupted on-disk file →
references/corruption.md
API references (api/)
Each class, interface, object, and enum has its own file. Filenames are the kebab-case form of the type name (DataStore → data-store.md, Preferences.Key → preferences-key.md, MultiProcessDataStoreFactory → multi-process-data-store-factory.md). A package's top-level and extension functions live in that package's package-functions.md. Each package is a sibling directory under api/ — run ls api/ to discover the packages and ls api/<package>/ for the full set within one.
Start here:
DataStore<T>→api/androidx.datastore.core/data-store.md— the core type; read via thedataFlow, write viaupdateData- Preferences (key-value) →
api/androidx.datastore.preferences.core/preferences.mdandapi/androidx.datastore.preferences.core/package-functions.md— the typed key builders (stringPreferencesKey, etc.),edit,emptyPreferences preferencesDataStoredelegate →api/androidx.datastore.preferences/package-functions.md— the entry point for a Preferences storedataStoredelegate →api/androidx.datastore/package-functions.md— the entry point for a typed (Proto/JSON) storeSerializer<T>→api/androidx.datastore.core/serializer.md— the contract a typed store's serializer implements- Corruption handling →
api/androidx.datastore.core.handlers/replace-file-corruption-handler.md— recover by replacing corrupt data
The api/ tree covers eleven packages, each in its own directory:
api/androidx.datastore/— top-level typed-store delegates (dataStore,deviceProtectedDataStore,Context.dataStoreFile).api/androidx.datastore.core/— the core types (DataStore,Serializer,Storage,DataMigration,CorruptionException,DataStoreFactory,MultiProcessDataStoreFactory, and the rest).api/androidx.datastore.core.handlers/— corruption handlers (ReplaceFileCorruptionHandler,ReThrowCorruptionHandler).api/androidx.datastore.core.okio/— Okio-backed storage and serializers (OkioStorage,OkioSerializer, plus the JavaScriptWebStorage/WebSerializer).api/androidx.datastore.migrations/—SharedPreferencesmigration (SharedPreferencesMigration,SharedPreferencesView).api/androidx.datastore.preferences/— thepreferencesDataStoredelegate andContext.preferencesDataStoreFile.api/androidx.datastore.preferences.core/—Preferences,MutablePreferences, the typedKeybuilders,PreferenceDataStoreFactory, andDataStore<Preferences>.edit.api/androidx.datastore.rxjava2/andapi/androidx.datastore.rxjava3/— RxJava-based typed stores (RxDataStore,RxDataStoreBuilder,RxDataMigration,RxSharedPreferencesMigration).api/androidx.datastore.preferences.rxjava2/andapi/androidx.datastore.preferences.rxjava3/— RxJava-based Preferences stores (RxPreferenceDataStoreBuilder,rxPreferencesDataStore).
Read the api/ file when you need to confirm a type's exact signature or members — not for how-to workflows, which live in references/.
What ships with it: 61 files
121.4 KB alongside SKILL.md, 1 of them executable
api/
- androidx.datastore.core/closeable.md554 B
- androidx.datastore.core/corruption-exception.md662 B
- androidx.datastore.core/corruption-handler.md1.3 KB
- androidx.datastore.core/data-migration.md2.4 KB
- androidx.datastore.core/data-store-builder.md1.5 KB
- androidx.datastore.core/data-store-factory.md3.5 KB
- androidx.datastore.core/data-store.md2.4 KB
- androidx.datastore.core/file-storage.md1.3 KB
- androidx.datastore.core.handlers/replace-file-corruption-handler.md1.4 KB
- androidx.datastore.core.handlers/re-throw-corruption-handler.md1.0 KB
- androidx.datastore.core/inter-process-coordinator.md2.2 KB
- androidx.datastore.core/io-exception.md898 B
- androidx.datastore.core/multi-process-data-store-factory.md2.4 KB
- androidx.datastore.core.okio/okio-serializer.md1.5 KB
- androidx.datastore.core.okio/okio-storage.md1.5 KB
- androidx.datastore.core.okio/package-functions.md543 B
- androidx.datastore.core.okio/web-serializer.md1.2 KB
- androidx.datastore.core.okio/web-storage.md1.0 KB
- androidx.datastore.core.okio/web-storage-type.md576 B
- androidx.datastore.core/package-functions.md2.3 KB
- androidx.datastore.core/read-scope.md506 B
- androidx.datastore.core/serializer.md1.4 KB
- androidx.datastore.core/storage-connection.md1.6 KB
- androidx.datastore.core/storage.md1.1 KB
- androidx.datastore.core/write-scope.md470 B
- androidx.datastore.migrations/shared-preferences-migration.md3.9 KB
- androidx.datastore.migrations/shared-preferences-view.md1.7 KB
- androidx.datastore/package-functions.md3.6 KB
- androidx.datastore.preferences.core/mutable-preferences.md2.7 KB
- androidx.datastore.preferences.core/package-functions.md4.2 KB
- androidx.datastore.preferences.core/preference-data-store-factory.md2.5 KB
- androidx.datastore.preferences.core/preferences-file-serializer.md1.4 KB
- androidx.datastore.preferences.core/preferences-key.md1.8 KB
- androidx.datastore.preferences.core/preferences.md2.5 KB
- androidx.datastore.preferences.core/preferences-pair.md502 B
- androidx.datastore.preferences.core/preferences-serializer.md1.2 KB
- androidx.datastore.preferences/package-functions.md4.5 KB
- androidx.datastore.preferences.rxjava2/package-functions.md2.0 KB
- androidx.datastore.preferences.rxjava2/rx-preference-data-store-builder.md2.8 KB
- androidx.datastore.preferences.rxjava3/package-functions.md2.0 KB
21 more files not listed here. See all 61 in the repository.