Skip to content

Commit acac949

Browse files
committed
update agents.md
1 parent 421cdd0 commit acac949

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ tests/tmp-*
4747
.kiro/
4848
CLAUDE.md
4949
GEMINI.md
50+
ANTIGRAVITY.md
5051
.cursorrules
5152

5253
# Go build artifacts (development)

AGENTS.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ Before any operation:
3535
- Validate syntax before suggesting changes: `bash -n <file>`
3636
- Use `gh` CLI for all GitHub operations (issues, PRs, releases, etc.)
3737
- Never commit code unless explicitly requested by user
38+
- Review and update `SECURITY_AUDIT.md` when modifying `clean` or `optimize` logic
3839

3940
---
4041

4142
## Quick Reference
4243

4344
### Build Commands
45+
4446
```bash
4547
# Build Go binaries for current platform
4648
make build
@@ -54,6 +56,7 @@ make clean
5456
```
5557

5658
### Test Commands
59+
5760
```bash
5861
# Run full test suite (recommended before commits)
5962
./scripts/test.sh
@@ -79,6 +82,7 @@ shellcheck --rcfile .shellcheckrc lib/**/*.sh bin/**/*.sh
7982
```
8083

8184
### Development Commands
85+
8286
```bash
8387
# Test cleanup in dry-run mode
8488
MO_DRY_RUN=1 ./mole clean
@@ -108,11 +112,17 @@ mole/ # Main CLI entrypoint (menu + routing)
108112
│ ├── purge.sh # Aggressive cleanup mode
109113
│ ├── touchid.sh # Touch ID sudo enabler
110114
│ ├── analyze.sh # Disk usage explorer wrapper
111-
│ └── status.sh # System health dashboard wrapper
115+
│ ├── status.sh # System health dashboard wrapper
116+
│ ├── installer.sh # Core installation logic
117+
│ └── completion.sh # Shell completion support
112118
├── lib/ # Reusable shell logic
113119
│ ├── core/ # base.sh, log.sh, sudo.sh, ui.sh
114-
│ ├── clean/ # Cleanup modules (user, apps, dev, caches, system)
115-
│ └── ui/ # Confirmation dialogs, progress bars
120+
│ ├── clean/ # Cleanup modules (user, apps, brew, system...)
121+
│ ├── optimize/ # Optimization modules
122+
│ ├── check/ # Health check modules
123+
│ ├── manage/ # Management utilities
124+
│ ├── ui/ # UI components (balloons, spinners)
125+
│ └── uninstall/ # Uninstallation logic
116126
├── cmd/ # Go applications
117127
│ ├── analyze/ # Disk analysis tool
118128
│ └── status/ # Real-time monitoring
@@ -130,6 +140,7 @@ mole/ # Main CLI entrypoint (menu + routing)
130140
- Tests → `tests/<test>.bats`
131141

132142
### Language Stack
143+
133144
- **Shell (Bash 3.2)**: Core cleanup and system operations (`lib/`, `bin/`)
134145
- **Go**: Performance-critical tools (`cmd/analyze/`, `cmd/status/`)
135146
- **BATS**: Integration testing (`tests/`)
@@ -139,6 +150,7 @@ mole/ # Main CLI entrypoint (menu + routing)
139150
## Code Style Guidelines
140151

141152
### Shell Scripts
153+
142154
- **Indentation**: 4 spaces (configured in .editorconfig)
143155
- **Variables**: `lowercase_with_underscores`
144156
- **Functions**: `verb_noun` format (e.g., `clean_caches`, `get_size`)
@@ -149,12 +161,14 @@ mole/ # Main CLI entrypoint (menu + routing)
149161
- **Error handling**: Use `set -euo pipefail` at top of files
150162

151163
### Go Code
164+
152165
- **Formatting**: Follow standard Go conventions (`gofmt`, `go vet`)
153166
- **Package docs**: Add package-level documentation for exported functions
154167
- **Error handling**: Never ignore errors, always handle them explicitly
155168
- **Build tags**: Use `//go:build darwin` for macOS-specific code
156169

157170
### Comments
171+
158172
- **Language**: English only
159173
- **Focus**: Explain "why" not "what" (code should be self-documenting)
160174
- **Safety**: Document safety boundaries explicitly
@@ -165,19 +179,22 @@ mole/ # Main CLI entrypoint (menu + routing)
165179
## Key Helper Functions
166180

167181
### Safety Helpers (lib/core/base.sh)
182+
168183
- `safe_rm <path>`: Safe deletion with validation
169184
- `safe_find_delete <base> <pattern> <days> <type>`: Protected find+delete
170185
- `is_protected <path>`: Check if path is system-protected
171186
- `is_whitelisted <name>`: Check user whitelist
172187

173188
### Logging (lib/core/log.sh)
189+
174190
- `log_info <msg>`: Informational messages
175191
- `log_success <msg>`: Success notifications
176192
- `log_warn <msg>`: Warnings
177193
- `log_error <msg>`: Error messages
178194
- `debug <msg>`: Debug output (requires MO_DEBUG=1)
179195

180196
### UI Helpers (lib/core/ui.sh)
197+
181198
- `confirm <prompt>`: Yes/no confirmation
182199
- `show_progress <current> <total> <msg>`: Progress display
183200

@@ -186,13 +203,15 @@ mole/ # Main CLI entrypoint (menu + routing)
186203
## Testing Strategy
187204

188205
### Test Types
206+
189207
1. **Syntax Validation**: `bash -n <file>` - catches basic errors
190208
2. **Unit Tests**: BATS tests for individual functions
191209
3. **Integration Tests**: Full command execution with BATS
192210
4. **Dry-run Tests**: `MO_DRY_RUN=1` to validate without deletion
193211
5. **Go Tests**: `go test -v ./cmd/...`
194212

195213
### Test Environment Variables
214+
196215
- `MO_DRY_RUN=1`: Preview changes without execution
197216
- `MO_DEBUG=1`: Enable detailed debug logging
198217
- `BATS_FORMATTER=pretty`: Use pretty output for BATS (default)
@@ -203,6 +222,7 @@ mole/ # Main CLI entrypoint (menu + routing)
203222
## Common Development Tasks
204223

205224
### Adding New Cleanup Module
225+
206226
1. Create `lib/clean/new_module.sh`
207227
2. Implement cleanup logic using `safe_*` helpers
208228
3. Source it in `bin/clean.sh`
@@ -211,13 +231,15 @@ mole/ # Main CLI entrypoint (menu + routing)
211231
6. Test with `MO_DRY_RUN=1` first
212232

213233
### Modifying Go Tools
234+
214235
1. Navigate to `cmd/<tool>/`
215236
2. Make changes to Go files
216237
3. Test with `go run .` or `make build && ./bin/<tool>-go`
217238
4. Run `go test -v` for unit tests
218239
5. Check integration: `./mole <command>`
219240

220241
### Debugging Issues
242+
221243
1. Enable debug mode: `MO_DEBUG=1 ./mole clean`
222244
2. Check logs for error messages
223245
3. Verify sudo permissions: `sudo -n true` or `./mole touchid`
@@ -229,15 +251,18 @@ mole/ # Main CLI entrypoint (menu + routing)
229251
## Linting and Quality
230252

231253
### Shell Script Linting
254+
232255
- **Tool**: shellcheck with custom `.shellcheckrc`
233256
- **Disabled rules**: SC2155, SC2034, SC2059, SC1091, SC2038
234257
- **Command**: `shellcheck --rcfile .shellcheckrc lib/**/*.sh bin/**/*.sh`
235258

236259
### Go Code Quality
260+
237261
- **Tools**: `go vet`, `go fmt`, `go test`
238262
- **Command**: `go vet ./cmd/... && go test ./cmd/...`
239263

240264
### CI/CD Pipeline
265+
241266
- **Triggers**: Push/PR to main, dev branches
242267
- **Platforms**: macOS 14, macOS 15
243268
- **Tools**: bats-core, shellcheck, Go 1.24.6
@@ -248,12 +273,14 @@ mole/ # Main CLI entrypoint (menu + routing)
248273
## File Organization Patterns
249274

250275
### Shell Modules
276+
251277
- Entry scripts in `bin/` should be thin wrappers
252278
- Reusable logic goes in `lib/`
253279
- Core utilities in `lib/core/`
254280
- Feature-specific modules in `lib/clean/`, `lib/ui/`, etc.
255281

256282
### Go Packages
283+
257284
- Each tool in its own `cmd/<tool>/` directory
258285
- Main entry point in `main.go`
259286
- Use standard Go project layout
@@ -266,6 +293,7 @@ mole/ # Main CLI entrypoint (menu + routing)
266293
### Use gh CLI for All GitHub Work
267294

268295
**Preferred Commands**:
296+
269297
```bash
270298
# Issues
271299
gh issue view 123 # View issue details
@@ -286,19 +314,22 @@ gh api repos/owner/repo/issues # Raw API access
286314
```
287315

288316
**NEVER use raw git commands for GitHub operations** when `gh` is available:
317+
289318
-`git log --oneline origin/main..HEAD` → ✅ `gh pr view`
290319
-`git remote get-url origin` → ✅ `gh repo view`
291320
- ❌ Manual GitHub API curl commands → ✅ `gh api`
292321

293322
## Error Handling Patterns
294323

295324
### Shell Scripts
325+
296326
- Use `set -euo pipefail` for strict error handling
297327
- Check command exit codes: `if command; then ...`
298328
- Provide meaningful error messages with `log_error`
299329
- Use cleanup traps for temporary resources
300330

301331
### Go Code
332+
302333
- Never ignore errors: `if err != nil { return err }`
303334
- Use structured error messages
304335
- Handle context cancellation appropriately
@@ -309,12 +340,14 @@ gh api repos/owner/repo/issues # Raw API access
309340
## Performance Considerations
310341

311342
### Shell Optimization
343+
312344
- Use built-in shell operations over external commands
313345
- Prefer `find -delete` over `-exec rm`
314346
- Minimize subprocess creation
315347
- Use appropriate timeout mechanisms
316348

317349
### Go Optimization
350+
318351
- Use concurrency for I/O-bound operations
319352
- Implement proper caching for expensive operations
320353
- Profile memory usage in scanning operations
@@ -325,12 +358,14 @@ gh api repos/owner/repo/issues # Raw API access
325358
## Security Best Practices
326359

327360
### Path Validation
361+
328362
- Always validate user-provided paths
329363
- Check against protection lists before operations
330364
- Use absolute paths to prevent directory traversal
331365
- Implement proper sandboxing for destructive operations
332366

333367
### Permission Management
368+
334369
- Request sudo only when necessary
335370
- Use `sudo -n true` to check sudo availability
336371
- Implement proper Touch ID integration
@@ -371,4 +406,4 @@ gh api repos/owner/repo/issues # Raw API access
371406

372407
---
373408

374-
**Remember**: When in doubt, err on the side of safety. It's better to clean less than to risk user data.
409+
**Remember**: When in doubt, err on the side of safety. It's better to clean less than to risk user data.

0 commit comments

Comments
 (0)