Skip to content

Commit 7745201

Browse files
Merge pull request #106 from contentstack/fix/dx-6048-update-cursor-rules-skills
docs(DX-6048): add AGENTS.md, skills, and Cursor rules entry
2 parents 7853179 + 35be9c0 commit 7745201

8 files changed

Lines changed: 135 additions & 198 deletions

File tree

.cursor/rules/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Cursor (optional)
2+
3+
**Cursor** users: start at **[AGENTS.md](../../AGENTS.md)**. All conventions live in **`skills/*/SKILL.md`**.
4+
5+
This folder only points contributors to **`AGENTS.md`** so editor-specific config does not duplicate the canonical docs.

AGENTS.md

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,43 @@
1-
# Contentstack Android CDA SDK – Agent Guide
1+
# Contentstack Android Delivery SDK – Agent guide
22

3-
This document is the main entry point for AI agents working in this repository.
3+
**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**.
44

5-
## Project
5+
## What this repo is
66

7-
- **Name:** Contentstack Android CDA SDK (contentstack-android)
8-
- **Purpose:** Android client for the Contentstack **Content Delivery API (CDA)**. It fetches content (entries, assets, content types, sync, etc.) from Contentstack for Android apps.
9-
- **Repo:** [contentstack-android](https://github.com/contentstack/contentstack-android)
7+
| Field | Detail |
8+
|--------|--------|
9+
| **Name:** | [contentstack-android](https://github.com/contentstack/contentstack-android) (`com.contentstack.sdk:android`) |
10+
| **Purpose:** | Android library for the Contentstack Content Delivery API (Kotlin/Java consumers via AAR). |
11+
| **Out of scope:** | Not the Java-only or iOS/Swift SDKs—those live in sibling repositories. |
1012

11-
## Tech stack
13+
## Tech stack (at a glance)
1214

13-
- **Languages:** Java (primary SDK source); Kotlin may appear in tests or future code. Target **Java 8** compatibility for the library (see `contentstack/build.gradle`).
14-
- **Build:** Gradle (Android Gradle Plugin), single module **`contentstack`** (AAR).
15-
- **Testing:** JUnit 4, Robolectric (unit tests on JVM), Mockito / PowerMock where used; **androidTest** with AndroidX Test / Espresso for instrumented tests; JaCoCo for coverage (`jacocoTestReport`).
16-
- **HTTP:** **Volley** (`CSHttpConnection`) for much of the CDA traffic; **Retrofit 2 + OkHttp + Gson** for paths such as taxonomy (`Stack`, `APIService`). OkHttp **MockWebServer** in unit tests.
15+
| Area | Details |
16+
|------|---------|
17+
| Language | Kotlin/Java; **compileSdk 34**; Java **17** compile options in `contentstack/build.gradle` |
18+
| Build | Gradle (root `build.gradle`, `settings.gradle`, module **`contentstack/`**) |
19+
| Tests | JUnit, Mockito, Robolectric, AndroidX Test—unit tests under `contentstack/src/test/` |
20+
| Lint / coverage | JaCoCo integrated with debug unit tests (`testCoverageEnabled` on debug) |
21+
| CI | `.github/workflows/check-branch.yml`, `publish-release.yml`, `sca-scan.yml`, `policy-scan.yml`, `codeql-analysis.yml` |
1722

18-
## Main entry points
23+
## Commands (quick reference)
1924

20-
- **`Contentstack`** – Factory: `Contentstack.stack(Context, apiKey, deliveryToken, environment)` (and overloads with `Config`) returns a **`Stack`**.
21-
- **`Stack`** – Main API: content types, entries, queries, assets, sync, etc.
22-
- **`Config`** – Optional configuration: host, version, region, branch, proxy, connection pool, endpoint.
23-
- **Paths:** `contentstack/src/main/java/com/contentstack/sdk/` (production), `contentstack/src/test/java/com/contentstack/sdk/` (unit tests), `contentstack/src/androidTest/java/` (instrumented tests).
25+
| Command type | Command |
26+
|--------------|---------|
27+
| Unit tests (typical) | `./gradlew :contentstack:testDebugUnitTest` (from repo root) |
28+
| Clean | `./gradlew clean` |
2429

25-
## Commands
30+
## Where the documentation lives: skills
2631

27-
Run from the **repository root** (requires Android SDK / `local.properties` for connected tests).
32+
| Skill | Path | What it covers |
33+
|-------|------|----------------|
34+
| **Development workflow** | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | Gradle, variants, CI, publishing |
35+
| **Android CDA SDK** | [`skills/contentstack-android-cda/SKILL.md`](skills/contentstack-android-cda/SKILL.md) | Library API and module boundaries |
36+
| **Android project layout** | [`skills/android/SKILL.md`](skills/android/SKILL.md) | `contentstack/` module, manifest, BuildConfig |
37+
| **Testing** | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | Unit vs instrumented tests, Robolectric, JaCoCo |
38+
| **Build & platform** | [`skills/framework/SKILL.md`](skills/framework/SKILL.md) | AGP, signing placeholders, `local.properties` |
39+
| **Code review** | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | PR checklist |
2840

29-
| Goal | Command |
30-
|------|---------|
31-
| **Build library (debug)** | `./gradlew :contentstack:assembleDebug` |
32-
| **Run all unit tests** | `./gradlew :contentstack:testDebugUnitTest` |
33-
| **Run instrumented / connected tests** | `./gradlew :contentstack:connectedDebugAndroidTest` (device or emulator required) |
34-
| **Unit + connected (full local test pass)** | `./gradlew :contentstack:testDebugUnitTest :contentstack:connectedDebugAndroidTest` |
35-
| **Coverage report (unit)** | `./gradlew :contentstack:jacocoTestReport` |
36-
37-
Instrumented tests may need **`local.properties`** entries (e.g. `APIKey`, `deliveryToken`, `environment`, `host`) for stacks that hit a real CDA endpoint—see `contentstack/build.gradle` `buildConfigField` usage.
38-
39-
## Rules and skills
40-
41-
- **`.cursor/rules/`** – Cursor rules for this repo:
42-
- **README.md** – Index of all rules (globs / always-on).
43-
- **dev-workflow.md** – Branches, tests, PR expectations.
44-
- **java.mdc** – Applies to `**/*.java` and `**/*.kt`: language style, `com.contentstack.sdk` layout, logging, null-safety.
45-
- **contentstack-android-cda.mdc** – SDK core: CDA patterns, Stack/Config, host/version/region/branch, retry, callbacks, CDA alignment.
46-
- **testing.mdc**`contentstack/src/test/**` and `contentstack/src/androidTest/**`: naming, unit vs instrumented, JaCoCo.
47-
- **code-review.mdc** – Always applied: PR/review checklist (aligned with Java CDA SDK).
48-
- **`skills/`** – Reusable skill docs:
49-
- **contentstack-android-cda** – Implementing or changing CDA behavior (Stack/Config, entries, assets, sync, HTTP, callbacks).
50-
- **testing** – Writing or refactoring tests.
51-
- **code-review** – PR review / pre-PR checklist.
52-
- **framework** – Config, HTTP layer (Volley + Retrofit/OkHttp), retry/timeouts.
53-
54-
Refer to `.cursor/rules/README.md` and `skills/README.md` for details.
41+
## Using Cursor (optional)
42+
43+
If you use **Cursor**, [`.cursor/rules/README.md`](.cursor/rules/README.md) only points to **`AGENTS.md`**—same docs as everyone else.

skills/android/SKILL.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: android
3+
description: Use for Android module layout, Gradle config, and Kotlin/Java conventions in contentstack-android.
4+
---
5+
6+
# Android project layout – contentstack-android
7+
8+
## When to use
9+
10+
- Editing `contentstack/build.gradle`, manifests, or source under `contentstack/src/`
11+
- Adjusting `minSdk`, multidex, or packaging excludes
12+
13+
## Instructions
14+
15+
### Source trees
16+
17+
- Follow standard Android library layout: **`main`**, **`test`**, **`androidTest`** under `contentstack/src/`.
18+
19+
### Configuration
20+
21+
- **`local.properties`** supplies machine-specific paths and optional keys—do not commit secrets; use the same keys the Gradle file expects (`host`, `APIKey`, etc. in `buildTypes`).
22+
23+
### Java/Kotlin
24+
25+
- Compile options target **Java 17** in the module—match language features accordingly.

skills/code-review/SKILL.md

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,27 @@
11
---
22
name: code-review
3-
description: Use when reviewing PRs or before opening a PR – API design, null-safety, exceptions, backward compatibility, dependencies, security, and test quality
3+
description: Use when reviewing PRs for contentstack-android—API stability, Gradle, tests, and mobile security.
44
---
55

6-
# Code Review – Contentstack Android CDA SDK
7-
8-
Use this skill when performing or preparing a pull request review for the Android CDA SDK. Aligns with the Java CDA SDK review bar.
6+
# Code review – contentstack-android
97

108
## When to use
119

12-
- Reviewing someone else’s PR.
13-
- Self-reviewing your own PR before submission.
14-
- Checking that changes meet project standards (API, errors, compatibility, tests, security).
10+
- Reviewing feature or fix PRs for the Android SDK
11+
- Auditing dependency or manifest changes
1512

1613
## Instructions
1714

18-
Work through the checklist below. Optionally tag items with severity: **Blocker**, **Major**, **Minor**.
19-
20-
### 1. API design and stability
21-
22-
- [ ] **Public API:** New or changed public methods/classes are necessary and documented (Javadoc with purpose and, where relevant, params/returns).
23-
- [ ] **Backward compatibility:** No breaking changes to public API unless explicitly agreed (e.g. major version). Deprecations should have alternatives and timeline.
24-
- [ ] **Naming:** Consistent with existing SDK style and CDA terminology (e.g. `Stack`, `Entry`, `Query`, `Config`).
25-
26-
**Severity:** Breaking public API without approval = Blocker. Missing docs on new public API = Major.
27-
28-
### 2. Error handling and robustness
29-
30-
- [ ] **Errors:** API failures are mapped to the SDK `Error` type and passed through existing callback/result patterns (e.g. `ResultCallBack`).
31-
- [ ] **Null safety:** No unintended NPEs; document or validate parameters for public API where it matters.
32-
- [ ] **Exceptions:** Checked exceptions are handled or declared; use of unchecked exceptions is intentional and documented where relevant.
33-
34-
**Severity:** Wrong or missing error handling in new code = Major.
35-
36-
### 3. Dependencies and security
37-
38-
- [ ] **Dependencies:** New or upgraded dependencies are justified. Version bumps are intentional and do not introduce known vulnerabilities.
39-
- [ ] **SCA:** Any security findings (e.g. Snyk, Dependabot) in the change set are addressed or explicitly deferred with a ticket.
40-
41-
**Severity:** New critical/high vulnerability = Blocker.
42-
43-
### 4. Testing
44-
45-
- [ ] **Coverage:** New or modified behavior has corresponding unit and/or instrumented tests.
46-
- [ ] **Conventions:** Tests follow naming (`Test*` for unit tests) and live in `src/test/` or `src/androidTest/` as appropriate.
47-
- [ ] **Quality:** Tests are readable, deterministic (no flakiness), and assert meaningful behavior.
48-
49-
**Severity:** No tests for new behavior = Blocker. Flaky or weak tests = Major.
50-
51-
### 5. Optional severity summary
15+
### Checklist
5216

53-
- **Blocker:** Must fix before merge (e.g. breaking API without approval, security issue, no tests for new code).
54-
- **Major:** Should fix (e.g. inconsistent error handling, missing Javadoc on new public API, flaky tests).
55-
- **Minor:** Nice to fix (e.g. style, minor docs, redundant code).
17+
- **API**: Public SDK surface changes justified and documented.
18+
- **Gradle**: Version bumps coherent; no accidental signing or secret commits.
19+
- **Tests**: Unit tests for new logic; consider Robolectric limitations.
20+
- **Manifest/resources**: No unnecessary permissions; ProGuard rules updated if needed.
21+
- **Cross-SDK**: Behavior consistent with Java/Swift where applicable.
5622

57-
## References
23+
### Severity hints
5824

59-
- Project rule: `.cursor/rules/code-review.mdc`
60-
- Testing skill: `skills/testing/SKILL.md` for test standards
25+
- **Blocker**: Broken `:contentstack:testDebugUnitTest`, leaked credentials, or broken publish metadata.
26+
- **Major**: Missing coverage for risky network or caching changes.
27+
- **Minor**: Formatting, comments, internal refactors.
Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,25 @@
11
---
22
name: contentstack-android-cda
3-
description: Use when implementing or changing CDA features – Stack/Config, entries, assets, sync, HTTP, callbacks, and Content Delivery API alignment
3+
description: Use for the public Android Content Delivery SDK surface and package com.contentstack.sdk.
44
---
55

6-
# Contentstack Android CDA SDK – CDA Implementation
7-
8-
Use this skill when implementing or changing Content Delivery API (CDA) behavior in the Android SDK.
6+
# Android CDA SDK – contentstack-android
97

108
## When to use
119

12-
- Adding or modifying Stack, Entry, Query, Asset, Content Type, or Sync behavior.
13-
- Changing Config options (host, version, region, branch, proxy, connection pool).
14-
- Working with the HTTP layer (CSHttpConnection/Volley, Stack/APIService/Retrofit/OkHttp) or callbacks and Error handling.
10+
- Changing SDK entry points consumed by Android apps
11+
- Working with stack configuration, entries, or HTTP client usage in this module
1512

1613
## Instructions
1714

18-
### Stack and Config
19-
20-
- **Entry point:** `Contentstack.stack(Context, apiKey, deliveryToken, environment)`. Overloads accept `Config` for host, version, region, branch, proxy, connection pool, endpoint.
21-
- **Defaults:** host `cdn.contentstack.io`, version `v3` (see `Config`). Region and branch via `Config.setRegion()`, `Config.setBranch()`.
22-
- **Reference:** `Contentstack.java`, `Stack.java`, `Config.java`.
23-
24-
### CDA resources
25-
26-
- **Entries:** `Stack.contentType(uid).entry(uid)`, query APIs, and entry fetch. Use existing `Entry`, `Query`, `EntriesModel`, and callback types.
27-
- **Assets:** `Stack.assetLibrary()`, asset fetch and query. Use `Asset`, `AssetLibrary`, `AssetModel`, and related callbacks.
28-
- **Content types:** Content type schema and listing. Use `ContentType`, `ContentTypesModel`, `ContentTypesCallback`.
29-
- **Sync:** Sync API usage. Use existing sync request/response and pagination patterns.
30-
- **Official API:** Align with [Content Delivery API](https://www.contentstack.com/docs/apis/content-delivery-api/) for parameters, response shape, and semantics.
31-
32-
### HTTP and retry
33-
34-
- **HTTP:** CDA requests use **CSHttpConnection** (Volley) and/or **Retrofit** + **OkHttp** (e.g. `Stack`, `APIService`). Set headers (User-Agent, auth) per constants and existing request building.
35-
- **Retry:** Volley retry is configured via `DefaultRetryPolicy` in `CSHttpConnection`; constants in `SDKConstant` (e.g. `TimeOutDuration`, `NumRetry`, `BackOFMultiplier`). Keep timeouts and retry behavior consistent when changing the HTTP layer.
36-
- **Reference:** `CSHttpConnection.java`, `CSConnectionRequest.java`, `Stack.java`, `APIService.java`, `SDKConstant.java`.
37-
38-
### Errors and callbacks
15+
### Module
3916

40-
- **Errors:** Map API errors to the `Error` class. Pass to the appropriate callback (e.g. `ResultCallBack`) so callers receive a consistent error shape.
41-
- **Callbacks:** Use existing callback types (`ResultCallBack`, `EntryResultCallBack`, `QueryResultsCallBack`, etc.). Do not change callback contracts without considering backward compatibility.
17+
- Primary code lives in **`contentstack/`** with namespace **`com.contentstack.sdk`** (`android { namespace ... }`).
4218

43-
## Key classes
19+
### API design
4420

45-
- **Entry points:** `Contentstack`, `Stack`, `Config`
46-
- **CDA:** `Entry`, `Query`, `Asset`, `AssetLibrary`, `ContentType`, sync-related classes
47-
- **HTTP:** `CSHttpConnection`, `CSConnectionRequest`, `APIService`, `Stack` (Retrofit)
48-
- **Errors / results:** `Error`, `QueryResult`, and callback interfaces in `com.contentstack.sdk`
21+
- Keep public Java/Kotlin APIs stable for app developers—use semver for breaking changes in published AARs.
4922

50-
## References
23+
### Integration
5124

52-
- [Content Delivery API – Contentstack Docs](https://www.contentstack.com/docs/apis/content-delivery-api/)
53-
- Project rules: `.cursor/rules/contentstack-android-cda.mdc`, `.cursor/rules/java.mdc`
25+
- Behavior should stay aligned with other CDA SDKs where features overlap (queries, preview, etc.)—check parity with Java/Swift docs when adding features.

skills/dev-workflow/SKILL.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: dev-workflow
3+
description: Use for Gradle tasks, CI, release publishing, and branch flow in contentstack-android.
4+
---
5+
6+
# Development workflow – contentstack-android
7+
8+
## When to use
9+
10+
- Running local builds/tests before a PR
11+
- Aligning with GitHub Actions (branch checks, SCA, publish)
12+
13+
## Instructions
14+
15+
### Project shape
16+
17+
- Root project **`contentstack-android`** includes module **`:contentstack`** (`settings.gradle`).
18+
19+
### Commands
20+
21+
- From repo root: `./gradlew :contentstack:testDebugUnitTest` for JVM unit tests on the library.
22+
- Use `./gradlew clean` when switching branches or after AGP/cache issues.
23+
24+
### CI
25+
26+
- Workflows under `.github/workflows/` enforce policies and may publish artifacts—coordinate version bumps with `contentstack/build.gradle` `PUBLISH_*` fields.

skills/framework/SKILL.md

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,25 @@
11
---
22
name: framework
3-
description: Use when touching config or HTTP layer – Config, CSHttpConnection (Volley), Stack/APIService (Retrofit/OkHttp), timeouts, retry, and error handling
3+
description: Use for AGP, Gradle plugins, JaCoCo, signing, and native Android build concerns in contentstack-android.
44
---
55

6-
# Framework – Contentstack Android CDA SDK
7-
8-
Use this skill when changing configuration or the HTTP connection layer (Volley and/or Retrofit/OkHttp).
6+
# Build & platform – contentstack-android
97

108
## When to use
119

12-
- Modifying **Config** options (host, version, region, branch, proxy, connection pool, endpoint).
13-
- Changing **CSHttpConnection** (Volley), request building, or **Stack**’s Retrofit/OkHttp setup.
14-
- Changing retry/timeout constants (e.g. `SDKConstant.TimeOutDuration`, `NumRetry`, `BackOFMultiplier`) or `DefaultRetryPolicy` usage.
15-
- Introducing or changing connection pooling, timeouts, or interceptors.
10+
- Upgrading Android Gradle Plugin, compile SDK, or dependencies
11+
- Fixing signing, packaging excludes, or multidex issues
1612

1713
## Instructions
1814

19-
### Config
20-
21-
- **Config** holds: host (default `cdn.contentstack.io`), version (default `v3`), environment, branch, region (`ContentstackRegion`), proxy, connection pool, endpoint, earlyAccess.
22-
- Use setter-style APIs (e.g. `setHost`, `setBranch`, `setRegion`). Preserve default values where existing behavior depends on them.
23-
- **Reference:** `contentstack/src/main/java/com/contentstack/sdk/Config.java`.
24-
25-
### Volley and CSHttpConnection
26-
27-
- **CSHttpConnection** uses **Volley** to execute requests. It is invoked via **CSConnectionRequest**; responses and errors are passed to the request’s callback (e.g. `onRequestFinished`).
28-
- **Retry:** Volley’s `DefaultRetryPolicy` is used in `CSHttpConnection` with constants from **SDKConstant** (e.g. `TimeOutDuration`, `NumRetry`, `BackOFMultiplier`). Keep retry/timeout behavior consistent when changing this path.
29-
- **Reference:** `CSHttpConnection.java`, `CSConnectionRequest.java`, `IRequestModelHTTP.java`, `SDKConstant.java`.
30-
31-
### Stack, Retrofit, and OkHttp
32-
33-
- **Stack** builds an **OkHttpClient** and **Retrofit** instance and uses **APIService** for certain CDA calls (e.g. taxonomy). Base URL and headers are derived from Config/stack state.
34-
- Do not bypass the shared client/Config when adding new CDA calls that use Retrofit.
35-
- **Reference:** `Stack.java`, `APIService.java`.
36-
37-
### Error handling
15+
### Gradle
3816

39-
- Map HTTP and API errors to the **Error** class. Pass errors through the same callback mechanism used elsewhere so callers get a consistent contract.
40-
- **Reference:** `Error.java`, and callback interfaces that receive errors.
17+
- Root **`build.gradle`** pins AGP and Nexus publish plugin versions; module plugin **`com.android.library`** applies in `contentstack/build.gradle`.
4118

42-
## Key classes
19+
### Publishing
4320

44-
- **Config:** `Config.java`, `ContentstackRegion`
45-
- **Volley path:** `CSHttpConnection.java`, `CSConnectionRequest.java`, `IRequestModelHTTP.java`, `SDKConstant.java`
46-
- **Retrofit path:** `Stack.java`, `APIService.java`
47-
- **Errors/callbacks:** `Error.java`, `ResultCallBack`, and related callback types
21+
- Maven coordinates use `PUBLISH_GROUP_ID`, `PUBLISH_ARTIFACT_ID`, `PUBLISH_VERSION`—bump with releases.
4822

49-
## References
23+
### Keystore
5024

51-
- Project rules: `.cursor/rules/contentstack-android-cda.mdc`, `.cursor/rules/java.mdc`
52-
- CDA skill: `skills/contentstack-android-cda/SKILL.md` for CDA-specific usage of Config and HTTP
25+
- Debug/release signing references **`key.keystore`** in the module—suitable for sample/debug only; production signing is consumer responsibility.

0 commit comments

Comments
 (0)