Skip to content

Commit 548fec0

Browse files
committed
Merge branch 'main' into release/7.58.0
2 parents 0bb907e + 806d76e commit 548fec0

File tree

800 files changed

+76401
-42166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

800 files changed

+76401
-42166
lines changed

.claude/commands/commit.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# PR Commit Agent
2+
3+
**Goal**: Create conventional commits with automated feedback loop for pre-commit hook failures.
4+
5+
## Core Principles
6+
7+
All commits must: Follow conventional commit format • Pass pre-commit hooks • Be descriptive and specific • Use automated fixes when possible
8+
9+
## Workflow
10+
11+
```bash
12+
# 1. Analyze staged changes
13+
git diff --cached --name-only && git diff --cached
14+
15+
# 2. Generate & execute commit
16+
git commit -m "<type>[optional scope]: <description>"
17+
18+
# 3. If pre-commit fails → Fix issues → Re-stage → Re-commit
19+
yarn lint-staged && git add <files> && git commit -m "<message>"
20+
```
21+
22+
## Decision Tree
23+
24+
```mermaid
25+
flowchart TD
26+
A[Start] --> B[Analyze staged files]
27+
B --> C[Generate conventional commit message]
28+
C --> D[Execute commit]
29+
D --> E{Pre-commit Hooks Pass?}
30+
E -->|Yes| F[Success]
31+
E -->|No| G[Fix ALL issues automatically]
32+
G --> H[Re-stage modified files]
33+
H --> D
34+
```
35+
36+
## Conventional Commit Format
37+
38+
**Structure**: `<type>[optional scope]: <description>`
39+
40+
**Types**: feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert
41+
42+
**Examples**:
43+
44+
```bash
45+
# ✅ Good
46+
feat: add NFT gallery to collectibles tab
47+
fix: resolve wallet connection timeout on cold start
48+
refactor: extract transaction formatter into utility
49+
test: add e2e spec for onboarding SRP import flow
50+
docs: update contributing guide with design-system usage
51+
chore: bump react-native to 0.74.5
52+
53+
# ❌ Bad (too vague, not imperative, or abbreviated)
54+
Add some stuff
55+
fixing bug
56+
refactor code
57+
tests
58+
update docs
59+
upgrade rn
60+
```
61+
62+
## Quality Standards
63+
64+
**Type Selection**:
65+
66+
-`feat: add user authentication``chore: add user authentication`
67+
-`fix: resolve memory leak``docs: resolve memory leak`
68+
69+
**Description Quality**:
70+
71+
- ✅ Specific: "add NFT gallery to collectibles tab"
72+
- ❌ Vague: "add stuff" or "fix bug"
73+
74+
**Scope Usage** (optional but useful):
75+
76+
-`fix(wallet): resolve connection timeout` - scope clarifies which feature area
77+
-`feat: add user onboarding flow` - no scope fine when spanning multiple areas
78+
-`feat(app): add NFT gallery` - "app" too generic, use specific area like "collectibles"
79+
80+
## Handling Pre-commit Hook Failures
81+
82+
**Common Issues & Fixes**:
83+
84+
- Lint-staged failures → `yarn lint-staged`
85+
- TypeScript errors → Fix type issues manually → `yarn lint:tsc`
86+
- Formatting issues → Auto-fixed by lint-staged
87+
- Import issues → `yarn eslint --fix <file>`
88+
89+
**Auto-fix Loop**:
90+
91+
```bash
92+
yarn lint-staged # Fix all auto-fixable issues
93+
git add <modified-files> # Re-stage fixed files
94+
git commit -m "<message>" # Re-run commit
95+
```
96+
97+
## Quick Commands
98+
99+
```bash
100+
git diff --cached --name-only # Check staged files
101+
git diff --cached # See staged changes
102+
git commit -m "<type>[scope]: <description>" # Commit
103+
yarn lint-staged # Fix lint issues
104+
git add <files> # Re-stage files
105+
```
106+
107+
## Success Metrics
108+
109+
Conventional format • Pre-commit hooks pass • No lint/format errors • Descriptive message
110+
111+
**Remember**: Fix all pre-commit hook issues automatically. Never skip hooks.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## Overview
2+
3+
Generate CLAUDE.md by dynamically aggregating all rules from `.cursor/rules/` directory. Works regardless of which rules exist or are added/removed.
4+
5+
## Steps
6+
7+
1. **Discover all rule files**
8+
9+
- Scan `.cursor/rules/` for all `.mdc` files
10+
- Extract title/name from each file (frontmatter or first heading)
11+
- Identify main sections and guidelines
12+
13+
2. **Analyze content dynamically**
14+
15+
- Extract core content (skip frontmatter)
16+
- Identify overlapping sections and consolidate
17+
- Determine logical organization based on content
18+
- Group related content semantically
19+
20+
3. **Generate structure**
21+
22+
- Create table of contents from discovered content
23+
- Organize into logical sections based on analysis
24+
- Use rule file names/titles as section headers
25+
26+
4. **Consolidate content**
27+
28+
- Merge all rules into appropriate sections
29+
- Remove duplicates automatically
30+
- Preserve formatting, examples, code blocks
31+
- Keep all enforcement rules
32+
- Maintain unique content from each file
33+
34+
5. **Handle CLAUDE.md existence**
35+
- If no file: Create new with consolidated content
36+
- If exists: Prompt user:
37+
```
38+
CLAUDE.md exists. Choose:
39+
1. Replace - Overwrite with new consolidated content
40+
2. Merge - Combine existing content with new rules
41+
```
42+
- Ensure proper markdown formatting
43+
- Maintain single source of truth
44+
45+
## Checklist
46+
47+
- [ ] All `.cursor/rules/` files analyzed
48+
- [ ] Structure planned and overlaps identified
49+
- [ ] CLAUDE.md existence checked
50+
- [ ] User preference obtained (if file exists)
51+
- [ ] CLAUDE.md created/updated with all content
52+
- [ ] Formatting, examples, enforcement preserved
53+
- [ ] Table of contents updated
54+
- [ ] Single source of truth maintained
55+
56+
## Dynamic Organization
57+
58+
1. **Analyze each file**: Extract headings, identify themes, determine logical flow
59+
2. **Create adaptive sections**: Use file names as headers, group related content, preserve hierarchy
60+
3. **Handle consolidation**: Merge duplicates, preserve unique content, keep original formatting
61+
4. **Generate TOC**: Based on discovered structure, ensure proper linking
62+
63+
## File Existence Handling
64+
65+
**No CLAUDE.md**: Create new file (no user interaction)
66+
67+
**CLAUDE.md exists**: Prompt user → "Replace" (overwrite) or "Merge" (combine)
68+
69+
## Success Criteria
70+
71+
- CLAUDE.md contains all rules from `.cursor/rules/`
72+
- Well-organized and easy to navigate
73+
- All formatting preserved
74+
- Duplicates consolidated
75+
- Works with any number of rule files (0 to N)
76+
- New rules auto-included, removed rules auto-excluded

.claude/commands/lint-staged.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# PR Lint-Staged Agent
2+
3+
**Goal**: Fix all linting and formatting issues on staged files with automated feedback loop.
4+
5+
## Core Principles
6+
7+
All staged files must: Pass lint-staged • Follow project standards • Use auto-fix when possible • No manual intervention required
8+
9+
## Workflow
10+
11+
```bash
12+
# 1. Run lint-staged
13+
yarn lint-staged
14+
15+
# 2. If errors → Fix automatically → Re-run
16+
# 3. Repeat until all issues resolved
17+
```

.claude/commands/unit-test-coverage.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,24 @@ cat scripts/reports/coverage-report-*.json | jq '.failedTests'
4646

4747
## Decision Tree
4848

49-
```
50-
Start → Load & Confirm Guidelines
51-
52-
Run coverage:analyze
53-
54-
[Failed Tests?] ──Yes──→ Fix ALL broken tests first
55-
↓ No ↓
56-
↓ Re-run coverage:analyze
57-
↓ ↓
58-
[newCodeCoverage < 80%?] ←──────┘
59-
↓ Yes
60-
[Can improve existing tests?] ──Yes──→ Add assertions to existing tests
61-
↓ No ↓
62-
Create minimal new tests Re-run coverage:analyze
63-
↓ ↓
64-
[Coverage Met] → Success ←──────────────────────┘
49+
```mermaid
50+
flowchart TD
51+
A[Start] --> B[Load and Confirm Guidelines]
52+
B --> C[Run coverage:analyze]
53+
C --> D{Failed Tests?}
54+
D -->|Yes| E[Fix ALL broken tests first]
55+
E --> F[Re-run coverage:analyze]
56+
F --> D
57+
D -->|No| G{newCodeCoverage less than 80%?}
58+
G -->|No| H[Success]
59+
G -->|Yes| I{Can improve existing tests?}
60+
I -->|Yes| J[Add assertions to existing tests]
61+
I -->|No| K[Create minimal new tests]
62+
J --> L[Re-run coverage:analyze]
63+
K --> L
64+
L --> M{Coverage Met?}
65+
M -->|No| I
66+
M -->|Yes| H
6567
```
6668

6769
## Handling Failed Tests (Priority #1)

.claude/commands/unit-test.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Unit Test Runner
2+
3+
**Goal**: Run unit tests for all changed files and their related test files.
4+
5+
## Steps
6+
7+
1. **Get changed files**
8+
9+
- Run `git diff --name-only --diff-filter=ACMR` for all changes (staged + unstaged)
10+
- Filter for `.js`, `.jsx`, `.ts`, `.tsx` files
11+
- Display list
12+
13+
2. **Find test files**
14+
15+
- Check if file is already a test file (contains `.test.`)
16+
- For source files, find related tests: `{basename}.test.{ext}`
17+
- Exclude snapshots (`.snap`)
18+
- Collect unique test files
19+
20+
3. **Run tests**
21+
22+
- Execute `yarn jest` with all found test files
23+
- Run without coverage
24+
- Capture results
25+
26+
4. **Report & fix**
27+
- Show pass/fail summary
28+
- If failures: Analyze → Fix issues → Re-run tests
29+
- Continue until all pass
30+
31+
## Checklist
32+
33+
- [ ] Changed files identified
34+
- [ ] Test files found
35+
- [ ] Tests executed
36+
- [ ] All tests pass
37+
- [ ] Issues fixed and re-tested if needed
38+
39+
## Failure Actions
40+
41+
1. Analyze failures → Isolate issues → Fix (implementation/mocks/tests) → Re-run → Repeat until pass
42+
43+
## Quick Commands
44+
45+
```bash
46+
yarn jest <filename> # Run test file
47+
yarn jest <filename> -t "test name" # Run specific test by name
48+
yarn jest <filename> --no-coverage # Faster execution (skip coverage)
49+
yarn jest <filename> --verbose # Detailed output for debugging
50+
```
51+
52+
## Success Criteria
53+
54+
All tests pass • No errors/timeouts • All changed files tested
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
globs: "**/*"
3+
alwaysApply: true
4+
---
5+
6+
# General Coding Guidelines
7+
8+
## Required Reading Before Development
9+
10+
**ALWAYS** check: `.github/guidelines/CODING_GUIDELINES.md` • `README.md` • Relevant `/docs` before coding
11+
12+
**Docs Structure**: `/docs/readme/` (core) • `/docs/` (features) • `README.md` (overview)
13+
14+
## Development Workflow
15+
16+
**Before Starting**: Read README.md → Check coding guidelines → Review relevant docs → Understand architecture
17+
18+
**Code Quality**:
19+
- TypeScript guidelines from contributor docs • Functional components + hooks • PascalCase (components) / camelCase (functions)
20+
- Reusable components/utilities • TSDoc format • Comprehensive tests • Apply `.cursor/rules/unit-testing-guidelines.mdc`
21+
22+
**File Organization**:
23+
```
24+
ComponentName/
25+
├── ComponentName.{constants,stories,styles,test,types}.ts(x)
26+
├── ComponentName.tsx
27+
├── README.md
28+
└── index.ts
29+
```
30+
31+
## Documentation Quick Reference
32+
33+
**Core**: `/docs/readme/` (architecture, testing, debugging, performance, environment, expo-environment, storybook, troubleshooting, expo-e2e-testing, reassure, release-build-profiler)
34+
35+
**Features**: `/docs/` (deeplinks, animations, tailwind, confirmations, confirmation-refactoring) • `app/component-library/README.md` • `e2e/MOCKING.md` • `CHANGELOG.md` • `app/core/{Analytics,Engine}/README.md` • `ppom/README.md`
36+
37+
**External**: [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) • [TypeScript Guidelines](https://github.com/MetaMask/contributor-docs/blob/main/docs/typescript.md) • [Unit Testing](https://github.com/MetaMask/contributor-docs/blob/main/docs/testing/unit-testing.md)
38+
39+
## Enforcement (MANDATORY)
40+
41+
**Documentation**: Read `.github/guidelines/`, `README.md`, and relevant `/docs` before implementing
42+
43+
**Commands**: ONLY use `.claude/commands/` + yarn command
44+
45+
**Testing**: see .claude/commands/unit-test.md
46+
47+
**Forbidden**: ❌ npm/npx commands

0 commit comments

Comments
 (0)