xiaohongshu
xiaohongshu
investigate-dependencies
Conduct thorough dependency audits to identify redundant code, unused features, and improper usage patterns. Examines each import to ensure we're leveraging existing capabilities rather than reinventing functionality.
Full skill instructions
Conduct line-by-line walkthroughs of modules to understand how we use external dependencies, identifying:
For each file under investigation, create an import inventory:
## Import Inventory for [filename]
| Import | Source | Purpose | Documentation |
|--------|--------|---------|---------------|
| `uuid` | stdlib | Generate unique identifiers | https://docs.python.org/3/library/uuid.html |
| `FastAPI` | fastapi | Web framework | https://fastapi.tiangolo.com/ |
| `CustomUtil` | local | [Document what we think it does] | [Internal docs] |
For each location where an external module is used:
### Usage Point: [Function/Method Name] (Lines X-Y)
**Code:**
```python
# Relevant code snippet showing dependency usage
Questions to Answer:
Findings:
### Step 3: Documentation Deep Dive
For each significant dependency, review:
1. **Official documentation** - What does the module actually do?
2. **API reference** - What methods/functions are available?
3. **Error handling** - What exceptions does it raise?
4. **Best practices** - How do the authors recommend using it?
5. **Source code** (if needed) - What does the implementation reveal?
### Step 4: Redundancy Detection
Common areas where redundancy occurs:
#### Utility Functions
```python
# ❌ REDUNDANT: Reimplementing datetime.now(UTC)
def get_current_time():
return datetime.datetime.now(datetime.timezone.utc)
# ✅ BETTER: Use the imported utility
from utils.timezone_utils import utc_now
current_time = utc_now() # Already exists in the codebase
# ❌ REDUNDANT: Manual JSON validation
def parse_json(data: str):
try:
result = json.loads(data)
if not isinstance(result, dict):
raise ValueError("Expected dict")
return result
except json.JSONDecodeError:
return None
# ✅ BETTER: Use Pydantic which handles this
from pydantic import BaseModel
class MyData(BaseModel):
# Pydantic handles JSON parsing, validation, and type checking
pass
# ❌ REDUNDANT: Manual UUID validation
def validate_uuid(value: str) -> bool:
try:
uuid.UUID(value)
return True
except ValueError:
return False
# ✅ BETTER: Use Pydantic's built-in UUID type
from uuid import UUID
from pydantic import BaseModel
class Request(BaseModel):
user_id: UUID # Pydantic validates this automatically
# ❌ REDUNDANT: Manual environment variable handling
def get_config():
host = os.getenv("DB_HOST", "localhost")
port = int(os.getenv("DB_PORT", "5432"))
# Manual type conversion, default handling, validation...
# ✅ BETTER: Use Pydantic Settings
from pydantic_settings import BaseSettings
class DatabaseConfig(BaseSettings):
db_host: str = "localhost"
db_port: int = 5432
# Pydantic handles env vars, types, defaults, validation
For each dependency, document:
## [Dependency Name] - Capability Analysis
### What We're Currently Using:
- [List actual usage]
### Available Capabilities We're Not Using:
- [Feature 1]: Could simplify [code location]
- [Feature 2]: Would eliminate [redundant implementation]
- [Feature 3]: Better error handling for [scenario]
### Recommendations:
1. [Specific refactoring suggestion with rationale]
2. [Another suggestion]
When conducting a dependency investigation, follow this structure:
# Dependency Investigation: [filename]
## Executive Summary
- **Total Imports**: X (Y external, Z internal)
- **Redundancies Found**: N instances
- **Unused Capabilities**: M opportunities
- **Severity**: HIGH/MEDIUM/LOW
## Import Inventory
[Table of all imports with documentation links]
## Detailed Findings
### [Import 1]
**Usage Locations**: Lines X, Y, Z
**Current Usage**: [What we're doing with it]
**Available Features**: [What else it offers]
**Issues Found**:
- [Redundancy, misuse, or missed opportunity]
**Recommendation**: [Specific action to take]
### [Import 2]
[Same structure]
## Refactoring Recommendations
### Priority 1: Critical Redundancies
1. [High-impact changes that eliminate significant redundancy]
### Priority 2: Capability Enhancements
2. [Changes that leverage unused features]
### Priority 3: Code Simplification
3. [Minor improvements and cleanup]
## Implementation Impact
- **Lines Removed**: ~X
- **Complexity Reduction**: [Qualitative assessment]
- **Maintainability**: [How this improves long-term maintenance]
Datetime Operations
datetime.now() instead of utils.timezone_utils.utc_now()?Type Validation
isinstance() checks vs. Pydantic modelsJSON Handling
json.loads/dumps vs. Pydantic's .model_dump_json()jsonable_encoderUUID Operations
Error Handling
Database Operations
Async Operations
Patterns that indicate potential redundancy:
A successful dependency investigation produces:
Request Format:
Please conduct a thorough walkthrough of [specific file/module], examining each line where we import or call external modules. For every external dependency referenced, investigate its source documentation and implementation to understand its full capabilities, error handling patterns, and intended usage. Document any instances where we're duplicating functionality that already exists in the imported module, implementing our own error handling for cases the module already covers, or not utilizing available features that could simplify our code. Pay special attention to utility functions, error handling, data validation, and configuration management - these are common areas where developers inadvertently reimplement existing functionality. The goal is to ensure we're properly leveraging our dependencies rather than writing redundant code, and that we're using these modules as their authors intended. Please create a summary noting any redundancies found and recommendations for refactoring to better utilize existing module capabilities.
The Principle: Every line of custom code is a maintenance burden. If a dependency we're already using can do it reliably and correctly, we should use it.
The Balance: Not all custom code is redundant. Sometimes we need custom logic for business requirements, performance optimization, or specific behavior. The investigation distinguishes between:
The Goal: A codebase that leverages dependencies fully, eliminating maintenance burden while preserving necessary custom logic.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience