Skip to content

Commit da13b6f

Browse files
riderxclaude
andcommitted
docs: add AGENTS.md with contribution and development guidelines
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1d7c199 commit da13b6f

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

AGENTS.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI agents and contributors working on this Capacitor plugin.
4+
5+
## Quick Start
6+
7+
```bash
8+
# Install dependencies
9+
bun install
10+
11+
# Build the plugin (TypeScript + Rollup + docgen)
12+
bun run build
13+
14+
# Full verification (iOS, Android, Web)
15+
bun run verify
16+
17+
# Format code (ESLint + Prettier + SwiftLint)
18+
bun run fmt
19+
20+
# Lint without fixing
21+
bun run lint
22+
```
23+
24+
## Development Workflow
25+
26+
1. **Install** - `bun install` (never use npm)
27+
2. **Build** - `bun run build` compiles TypeScript, generates docs, and bundles with Rollup
28+
3. **Verify** - `bun run verify` builds for iOS, Android, and Web. Always run this before submitting work
29+
4. **Format** - `bun run fmt` auto-fixes ESLint, Prettier, and SwiftLint issues
30+
5. **Lint** - `bun run lint` checks code quality without modifying files
31+
32+
### Individual Platform Verification
33+
34+
```bash
35+
bun run verify:ios
36+
bun run verify:android
37+
bun run verify:web
38+
```
39+
40+
### Example App
41+
42+
If an `example-app/` directory exists, you can test the plugin locally:
43+
44+
```bash
45+
cd example-app
46+
bun install
47+
bun run start
48+
```
49+
50+
The example app references the plugin via `file:..`. Use `bunx cap sync <platform>` to sync native platforms.
51+
52+
## Project Structure
53+
54+
- `src/definitions.ts` - TypeScript interfaces and types (source of truth for API docs)
55+
- `src/index.ts` - Plugin registration
56+
- `src/web.ts` - Web implementation
57+
- `ios/Sources/` - iOS native code (Swift)
58+
- `android/src/main/` - Android native code (Java/Kotlin)
59+
- `dist/` - Generated output (do not edit manually)
60+
- `Package.swift` - SwiftPM definition
61+
- `*.podspec` - CocoaPods spec
62+
63+
## iOS Package Management
64+
65+
We always support both **CocoaPods** and **Swift Package Manager (SPM)**. Every plugin must ship a valid `*.podspec` and `Package.swift`. Do not remove or break either integration — users depend on both.
66+
67+
## API Documentation
68+
69+
API docs in the README are auto-generated from JSDoc in `src/definitions.ts`. **Never edit the `<docgen-index>` or `<docgen-api>` sections in README.md directly.** Instead, update `src/definitions.ts` and run `bun run docgen` (also runs as part of `bun run build`).
70+
71+
## Versioning
72+
73+
The plugin major version follows the Capacitor major version (e.g., plugin v8 for Capacitor 8). **We only ship breaking changes when a new Capacitor native major version is released.** All other changes must be backward compatible.
74+
75+
## Changelog
76+
77+
`CHANGELOG.md` is managed automatically by CI/CD. Do not edit it manually.
78+
79+
## Pull Request Guidelines
80+
81+
We welcome contributions, including AI-generated pull requests. Every PR must include:
82+
83+
### Required Sections
84+
85+
1. **What** - What does this PR change?
86+
2. **Why** - What is the reason for this change?
87+
3. **How** - How did you approach the implementation?
88+
4. **Testing** - What did you test? How did you verify it works?
89+
5. **Not Tested** - What is not yet tested or needs further validation?
90+
91+
### Rules
92+
93+
- **No breaking changes** unless aligned with a new Capacitor major release.
94+
- Run `bun run verify` and `bun run fmt` before opening a PR. CI will catch failures, but catching them locally saves time.
95+
- If you are an AI agent, that is perfectly fine. Just be transparent about it. We care that the code is correct and helpful, not who wrote it.
96+
- We review PRs on a best-effort basis. We may request changes — you are expected to address them for the PR to be merged.
97+
- We use automated code review tools (CodeRabbit, and others). You will need to respond to their feedback and resolve any issues they raise.
98+
- We have automatic releases. Once merged, your change will ship in the next release cycle.
99+
100+
### PR Template
101+
102+
```
103+
## What
104+
- [Brief description of the change]
105+
106+
## Why
107+
- [Motivation for this change]
108+
109+
## How
110+
- [Implementation approach]
111+
112+
## Testing
113+
- [What was tested and how]
114+
115+
## Not Tested
116+
- [What still needs testing, if anything]
117+
```
118+
119+
## Common Pitfalls
120+
121+
- Always rename Swift/Java classes and package IDs when creating a new plugin from a template — leftover names cause registration conflicts.
122+
- We only use Java 21 for Android builds.
123+
- Keep temporary files clean: delete or mark with `deleteOnExit` after use.
124+
- `dist/` is fully regenerated on every build — never edit generated files.
125+
- Use Bun for everything. Do not use npm or npx. Use `bunx` if you need to run a package binary.

0 commit comments

Comments
 (0)