Skip to content
Back to skills

Coding.Make Function Private

ASecurity

Identify private or public functions in a file and rename with underscore

  • 158 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 7, 2026
testingpythongobashapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add gpsaggese/helpers --skill coding.make_function_private --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coding.Make Function Private?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coding.Make Function Private
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gpsaggese-coding-make-function-private/badge)](https://www.skillsdirectory.com/skills/gpsaggese-coding-make-function-private)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Identify private or public functions in a file and rename with underscore
model: haiku
---

# Goal
For each function `<FUNC>` in the passed Python file `<FILE>`, decide if it is
private or public by checking whether Python files or Jupyter notebooks outside
`<FILE>` call it.

# Conventions
- Follow `## Mark Private Functions` in `.claude/skills/coding.rules.md`

# Definitions

## External Files
- **External files** = any Python file or Jupyter notebook outside the target
  file
  - Including:
    - Sibling scripts in the same package (e.g., `notes_to_pdf.py` calling
      functions from `lib_notes_to_pdf.py`)
    - Parent/sibling modules that import from the target
    - CLI entry point scripts
  - Excluding:
    - Test files of the target. A function stays private even if a test calls it

- **Note:** Functions in a library module's public API are PUBLIC, even if no
  `__main__` entry point calls them. Utilities that other scripts in the package
  import are PUBLIC too

# Private Functions
- If `<FUNC>` is not called by any external file, it is private: rename it with a
  `_` prefix
  - E.g., `def function` -> `def _function`
  - Include only internal utilities, helpers, and implementation details
- Update all callers of `<FUNC>` to the new name

- **Good** (only called within its own file, so renamed private)
  ```python
  # lib_helper.py
  def public_function():
      _internal_helper()  # Only called within this file, so private.

  def _internal_helper():
      pass
  ```

# Public Functions
- If `<FUNC>` is called by external files, it is public: its name must not start
  with `_`
  - This includes functions in shared utility modules that sibling scripts call
- Update all callers, external and internal, to the new name

- **Good** (called by an external file, so it stays public)
  ```python
  # lib_notes_to_pdf.py
  def preprocess_notes(file_name, prefix):  # Called by notes_to_pdf.py, so public.
      _internal_step_1(file_name)  # Private helper.

  def _internal_step_1(file_name):  # Only used within lib_notes_to_pdf.py, so private.
      pass
  ```

# Workflow

## Find All Functions
- Find all functions in `<FILE>`

## Search for External Calls
- For each function, search the whole codebase:
  ```bash
  grep -r "<FUNC>" --include="*.py" --include="*.ipynb" --exclude="test_*.py"
  ```

## Classify and Rename
- Classify each function as public or private from its external usage
- Rename functions and update all call sites (in both files)
- Verify the changes

# Verification
- [ ] Grep the entire codebase to confirm all calls were renamed correctly
      ```bash
      grep -r "old_name\|new_name" --include="*.py" --include="*.ipynb"
      ```
- [ ] Run pyright to verify type correctness of modified function invocations
- [ ] Run unit tests for the modified files to ensure nothing broke

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.