@moon791017/neo-skills 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GEMINI.md +115 -0
- package/README.md +155 -0
- package/bin/install-claude-skills.js +72 -0
- package/commands/neo/cd-app-service.toml +20 -0
- package/commands/neo/cd-iis.toml +20 -0
- package/commands/neo/ci-dotnet.toml +21 -0
- package/commands/neo/clarification.toml +48 -0
- package/commands/neo/code-review.toml +33 -0
- package/commands/neo/dotnet-gen-interface.toml +31 -0
- package/commands/neo/explain.toml +44 -0
- package/commands/neo/git-commit.toml +49 -0
- package/dist/hooks/secret-guard.js +2 -0
- package/dist/server.js +220 -0
- package/gemini-extension.json +15 -0
- package/package.json +39 -0
- package/skills/azure-pipelines/SKILL.md +45 -0
- package/skills/azure-pipelines/templates/build/build-dotnet.yml +92 -0
- package/skills/azure-pipelines/templates/deploy/deploy-app-service.yml +71 -0
- package/skills/azure-pipelines/templates/deploy/deploy-iis.yml +189 -0
- package/skills/azure-pipelines/templates/util/clean-artifact.yml +40 -0
- package/skills/azure-pipelines/templates/util/extract-artifact.yml +57 -0
- package/skills/azure-pipelines/templates/util/iis/iis-backup.yml +92 -0
- package/skills/azure-pipelines/templates/util/iis/iis-deploy-files.yml +112 -0
- package/skills/azure-pipelines/templates/util/iis/iis-manage-website.yml +112 -0
- package/skills/azure-pipelines/templates/util/iis/iis-rollback.yml +98 -0
- package/skills/azure-pipelines/templates/util/iis/iis-start-website.yml +89 -0
- package/skills/azure-pipelines/templates/util/iis/iis-stop-website.yml +80 -0
- package/skills/azure-pipelines/templates/util/iis/iis-task.yml +157 -0
- package/skills/azure-pipelines/templates/util/set-aspnetcore-env.yml +77 -0
- package/skills/clarification/SKILL.md +22 -0
- package/skills/code-review/SKILL.md +72 -0
- package/skills/csharp/SKILL.md +87 -0
- package/skills/csharp/reference/anti-patterns.md +142 -0
- package/skills/csharp/reference/coding-style.md +86 -0
- package/skills/csharp/reference/patterns.md +142 -0
- package/skills/csharp-interface-generator/SKILL.md +40 -0
- package/skills/dotnet/SKILL.md +41 -0
- package/skills/dotnet-ef-core/SKILL.md +78 -0
- package/skills/dotnet-ef-core/reference/anti-patterns.md +51 -0
- package/skills/dotnet-ef-core/reference/coding-style.md +42 -0
- package/skills/dotnet-ef-core/reference/patterns.md +53 -0
- package/skills/dotnet-minimal-apis/SKILL.md +78 -0
- package/skills/dotnet-minimal-apis/reference/anti-patterns.md +59 -0
- package/skills/dotnet-minimal-apis/reference/coding-style.md +54 -0
- package/skills/dotnet-minimal-apis/reference/patterns.md +68 -0
- package/skills/dotnet-mvc/SKILL.md +78 -0
- package/skills/dotnet-mvc/reference/anti-patterns.md +49 -0
- package/skills/dotnet-mvc/reference/coding-style.md +43 -0
- package/skills/dotnet-mvc/reference/patterns.md +56 -0
- package/skills/dotnet-webapi/SKILL.md +78 -0
- package/skills/dotnet-webapi/reference/anti-patterns.md +48 -0
- package/skills/dotnet-webapi/reference/coding-style.md +47 -0
- package/skills/dotnet-webapi/reference/patterns.md +52 -0
- package/skills/explain/SKILL.md +27 -0
- package/skills/git-commit/SKILL.md +84 -0
- package/skills/python/SKILL.md +61 -0
- package/skills/python/reference/anti-patterns.md +177 -0
- package/skills/python/reference/coding-style.md +92 -0
- package/skills/python/reference/patterns.md +112 -0
- package/skills/python-manager/SKILL.md +61 -0
- package/skills/start-plan/SKILL.md +29 -0
- package/skills/swift/SKILL.md +78 -0
- package/skills/swift/reference/anti-patterns.md +75 -0
- package/skills/swift/reference/coding-style.md +56 -0
- package/skills/swift/reference/patterns.md +94 -0
- package/skills/swift-ui/SKILL.md +76 -0
- package/skills/swift-ui/reference/anti-patterns.md +52 -0
- package/skills/swift-ui/reference/coding-style.md +46 -0
- package/skills/swift-ui/reference/patterns.md +87 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# SwiftUI Anti-Patterns and Best Practices
|
|
2
|
+
|
|
3
|
+
## 1. The "God View"
|
|
4
|
+
**Problem**: A single view contains excessive functionality, leading to a `body` that exceeds 100 lines.
|
|
5
|
+
**Impact**: Code becomes difficult to maintain, and performance decreases during re-rendering.
|
|
6
|
+
**Recommendation**: Split the view into smaller, single-responsibility `struct` views.
|
|
7
|
+
|
|
8
|
+
## 2. In-View Logic
|
|
9
|
+
**Problem**: Writing complex conditional logic, mathematical calculations, or network calls within `body` or View Modifiers.
|
|
10
|
+
**Impact**: View rendering becomes unstable and difficult to unit test.
|
|
11
|
+
**Recommendation**: Move logic to a ViewModel (traditional projects) or Model (projects using `@Observable`).
|
|
12
|
+
|
|
13
|
+
## 3. Excessive use of `AnyView`
|
|
14
|
+
**Problem**: Frequently using `AnyView` to erase types.
|
|
15
|
+
**Impact**: SwiftUI cannot optimize the view tree, leading to significant rendering performance issues.
|
|
16
|
+
**Recommendation**: Prioritize the use of `@ViewBuilder`, `Group`, or `if-else`.
|
|
17
|
+
|
|
18
|
+
```swift
|
|
19
|
+
// Bad
|
|
20
|
+
func content() -> AnyView {
|
|
21
|
+
if isTrue {
|
|
22
|
+
return AnyView(Text("True"))
|
|
23
|
+
} else {
|
|
24
|
+
return AnyView(Circle())
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Good
|
|
29
|
+
@ViewBuilder
|
|
30
|
+
func content() -> some View {
|
|
31
|
+
if isTrue {
|
|
32
|
+
Text("True")
|
|
33
|
+
} else {
|
|
34
|
+
Circle()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 4. Forced Unwrapping in `body`
|
|
40
|
+
**Problem**: Using `!` to force unwrap optional types within `body`.
|
|
41
|
+
**Impact**: The application will crash directly when rendering an incomplete state.
|
|
42
|
+
**Recommendation**: Always use `if let` or `guard let` (within helper functions) to provide safe fallback content.
|
|
43
|
+
|
|
44
|
+
## 5. Unnecessary `@State` Updates
|
|
45
|
+
**Problem**: Modifying `@State` during the view rendering process (Side Effect).
|
|
46
|
+
**Impact**: Leads to update cycles or infinite loop crashes.
|
|
47
|
+
**Recommendation**: Only modify state when triggered by actions (e.g., `.onAppear`, `onTapGesture`).
|
|
48
|
+
|
|
49
|
+
## 6. Deprecated Navigation Patterns
|
|
50
|
+
**Problem**: Still using `NavigationView` in iOS 16+ projects.
|
|
51
|
+
**Impact**: Lacks support for modern data-driven navigation.
|
|
52
|
+
**Recommendation**: Fully migrate to `NavigationStack` and `NavigationPath`.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# SwiftUI Coding Style and Naming Conventions
|
|
2
|
+
|
|
3
|
+
## View Declaration
|
|
4
|
+
- **View Name**: Should use `PascalCase` and be named after its functionality (e.g., `UserProfileView.swift`).
|
|
5
|
+
- **Structs over Classes**: Views should always be defined as `struct` and conform to the `View` protocol.
|
|
6
|
+
|
|
7
|
+
## View Body Structure
|
|
8
|
+
- **Keep `body` Clean**: The `body` should not contain complex calculation logic, network requests, or data processing.
|
|
9
|
+
- **Sub-view Deconstruction**:
|
|
10
|
+
- When the `body` exceeds 30-50 lines, it should be considered for splitting into independent sub-views.
|
|
11
|
+
- Prioritize using `struct` sub-views over computed properties (`var subview: some View`).
|
|
12
|
+
|
|
13
|
+
## View Modifier Ordering
|
|
14
|
+
The order of modifiers affects the rendering result. Follow this logical sequence:
|
|
15
|
+
1. **Layout**: `frame`, `padding`, `layoutPriority`.
|
|
16
|
+
2. **Effects**: `background`, `border`, `shadow`, `clipShape`, `opacity`.
|
|
17
|
+
3. **Interaction**: `onTapGesture`, `onHover`.
|
|
18
|
+
4. **Positioning**: `offset`, `position`.
|
|
19
|
+
|
|
20
|
+
```swift
|
|
21
|
+
// Good
|
|
22
|
+
Text("Hello")
|
|
23
|
+
.frame(maxWidth: .infinity) // 1. Layout
|
|
24
|
+
.background(Color.blue) // 2. Effects
|
|
25
|
+
.onTapGesture { ... } // 3. Interaction
|
|
26
|
+
|
|
27
|
+
// Bad
|
|
28
|
+
Text("Hello")
|
|
29
|
+
.background(Color.blue) // The background will follow the text only, not the frame
|
|
30
|
+
.frame(maxWidth: .infinity)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## State Management Naming
|
|
34
|
+
- **Private State (@State)**: Should be marked as `private`.
|
|
35
|
+
- **Two-way Binding (@Binding)**: Should be clearly named, reflecting the data it represents rather than the UI behavior.
|
|
36
|
+
|
|
37
|
+
## Preview Patterns (iOS 17+)
|
|
38
|
+
- Always use the `#Preview` macro for view development.
|
|
39
|
+
- Provide mock data and ensure testing for Dark Mode and Dynamic Type.
|
|
40
|
+
|
|
41
|
+
```swift
|
|
42
|
+
#Preview {
|
|
43
|
+
UserProfileView(user: User.mock)
|
|
44
|
+
.preferredColorScheme(.dark)
|
|
45
|
+
}
|
|
46
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Modern SwiftUI Patterns (iOS 16+)
|
|
2
|
+
|
|
3
|
+
## 1. View Composition (Small Views)
|
|
4
|
+
**Concept**: Splitting large UIs into multiple small views.
|
|
5
|
+
**Advantages**: Clearer code, easier testing, and reduced Swift compilation time.
|
|
6
|
+
|
|
7
|
+
```swift
|
|
8
|
+
struct UserCard: View {
|
|
9
|
+
let user: User
|
|
10
|
+
var body: some View {
|
|
11
|
+
HStack {
|
|
12
|
+
UserAvatar(imageName: user.avatar)
|
|
13
|
+
UserInfoDetails(name: user.name, email: user.email)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 2. Modern Observation (iOS 17+)
|
|
20
|
+
**Pattern**: Using the `@Observable` macro for state management.
|
|
21
|
+
**Features**: Eliminates the need for `@Published` annotations, automatically tracks properties, and provides better rendering performance.
|
|
22
|
+
|
|
23
|
+
```swift
|
|
24
|
+
@Observable
|
|
25
|
+
class AppState {
|
|
26
|
+
var count = 0
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
struct CounterView: View {
|
|
30
|
+
@State private var state = AppState()
|
|
31
|
+
var body: some View {
|
|
32
|
+
Button("Count: \(state.count)") { state.count += 1 }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 3. Custom View Modifiers
|
|
38
|
+
**Purpose**: Encapsulating common styles or behaviors (e.g., standard button styles).
|
|
39
|
+
**Advantages**: Provides a unified design language and reduces confusion within the view hierarchy.
|
|
40
|
+
|
|
41
|
+
```swift
|
|
42
|
+
struct BrandButtonModifier: ViewModifier {
|
|
43
|
+
func body(content: Content) -> some View {
|
|
44
|
+
content
|
|
45
|
+
.padding()
|
|
46
|
+
.background(Color.blue)
|
|
47
|
+
.foregroundColor(.white)
|
|
48
|
+
.clipShape(Capsule())
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
extension View {
|
|
53
|
+
func brandButtonStyle() -> some View {
|
|
54
|
+
modifier(BrandButtonModifier())
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 4. Modern Navigation (iOS 16+)
|
|
60
|
+
**Recommendation**: Use `NavigationStack` combined with path binding (`Path Binding`).
|
|
61
|
+
**Advantages**: Complete control over the navigation stack, supporting deep linking.
|
|
62
|
+
|
|
63
|
+
```swift
|
|
64
|
+
struct MainApp: View {
|
|
65
|
+
@State private var path = NavigationPath()
|
|
66
|
+
var body: some View {
|
|
67
|
+
NavigationStack(path: $path) {
|
|
68
|
+
List(Items) { item in
|
|
69
|
+
NavigationLink(value: item) { Text(item.name) }
|
|
70
|
+
}
|
|
71
|
+
.navigationDestination(for: Item.self) { item in
|
|
72
|
+
DetailView(item: item)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 5. ViewThatFits
|
|
80
|
+
**Purpose**: Automatically select the appropriate layout across different device sizes (e.g., iPhone mini vs. iPhone Pro Max).
|
|
81
|
+
|
|
82
|
+
```swift
|
|
83
|
+
ViewThatFits {
|
|
84
|
+
HStack { ... } // Try first
|
|
85
|
+
VStack { ... } // Fallback here if width is insufficient
|
|
86
|
+
}
|
|
87
|
+
```
|