Centralize External Namespace Imports

VerifiedSafe

Centralize external namespace imports (BCL, FCL, NuGet) in a GlobalUsings.cs file per project, keeping individual files clean.

Sby Skills Guide Bot
DevelopmentIntermediate
7/23/2026
Claude CodeCursorWindsurfCopilotCodex
#csharp#dotnet#code-organization#global-usings#using-directives

Recommended for

Automated summary

Centralizes external namespace imports (BCL, FCL, NuGet) in a GlobalUsings.cs file per project, keeping individual files clean.

Strengths

  • Reduces repetitive using directives across all files
  • Centralizes management of common namespaces in one place
  • Improves code readability by decluttering individual files
  • Ensures consistent usage of namespaces throughout the project

Limitations

  • Not suitable for internal project namespaces which should remain explicit
  • Can lead to over-declaration if rarely-used namespaces are added
  • Requires team discipline to keep the file updated
When to use it

When multiple files in a .NET project share the same external namespaces (BCL, FCL, or NuGet) and you want to reduce repetition.

When not to use it

For internal project namespaces or rarely-used namespaces, as it can hide dependencies and reduce code clarity.

Security analysis

Safe
Quality score90/100

This skill is a documentation/guideline for C# project organization. It involves no code execution, no tools, no network access, and no destructive or sensitive actions. It merely describes best practices for managing using directives.

No concerns found

How this analysis is made

Examples

Create GlobalUsings.cs
Create a GlobalUsings.cs file in the root of my .NET project that includes global using directives for common System.* namespaces (System.Net, System.Text, System.Text.Json) and NuGet packages (Bogus, Moq, Microsoft.AspNetCore.Mvc.Testing).
Refactor to use global usings
Refactor my .NET solution to centralize external using directives (BCL and NuGet) in a GlobalUsings.cs per project. Remove redundant using statements from individual files where those namespaces are globally declared.
Add new namespace to GlobalUsings.cs
Add a global using for the Newtonsoft.Json namespace to my existing GlobalUsings.cs file in the Api project, and ensure all files that use it no longer have a redundant using statement.

name: managing-global-usings description: Centralize external namespace imports (BCL, FCL, NuGet) in a GlobalUsings.cs file per project, keeping individual files clean.

GlobalUsings.cs로 외부 네임스페이스 중앙 관리

설명

프로젝트 내에서 반복적으로 사용되는 외부 네임스페이스(System.*, NuGet 패키지 등)를 GlobalUsings.cs 파일에 global using으로 선언하여 개별 파일의 using 문을 최소화합니다.

규칙

  • 각 프로젝트 루트에 GlobalUsings.cs 파일을 생성합니다
  • .NET BCL/FCL 네임스페이스(System.*, Microsoft.* 등)는 global using으로 등록합니다
  • NuGet 패키지 네임스페이스(Bogus, Moq, Scalar.AspNetCore 등)는 global using으로 등록합니다
  • 솔루션 내부 프로젝트의 네임스페이스(예: CompanyC.Api)는 global using에 등록하지 않습니다
  • 개별 파일에서는 GlobalUsings.cs에 등록된 네임스페이스의 using 문을 제거합니다
  • 알파벳 순으로 정렬합니다

Worst Case (나쁜 예)

// EmployeeApiTests.cs - 모든 파일마다 동일한 using 반복
using System.Net;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using Microsoft.AspNetCore.Mvc.Testing;

namespace CompanyC.Api.IntegrationTests;

public class EmployeeApiTests { ... }
// EmployeeBogusTests.cs - 같은 using 또 반복
using System.Net;
using System.Text;
using System.Text.Json;
using CompanyC.Api;
using Microsoft.AspNetCore.Mvc.Testing;

namespace CompanyC.Api.IntegrationTests;

public class EmployeeBogusTests { ... }

Best Case (좋은 예)

// GlobalUsings.cs - 외부 네임스페이스를 한 곳에서 관리
global using System.Net;
global using System.Net.Http.Headers;
global using System.Text;
global using System.Text.Json;
global using Bogus;
global using Microsoft.AspNetCore.Mvc.Testing;
global using Microsoft.Extensions.DependencyInjection;
global using Moq;
// EmployeeApiTests.cs - 외부 using 없이 깔끔
namespace CompanyC.Api.IntegrationTests;

public class EmployeeApiTests { ... }
// EmployeeBogusTests.cs - 내부 네임스페이스만 유지
using CompanyC.Api;

namespace CompanyC.Api.IntegrationTests;

public class EmployeeBogusTests { ... }

적용 대상

  • 솔루션 내 모든 프로젝트 (API, 테스트, 도구)
  • .NET BCL/FCL 네임스페이스 (System.*, Microsoft.*)
  • NuGet 패키지 네임스페이스
  • 2개 이상의 파일에서 사용되는 외부 네임스페이스

제외 대상

  • 솔루션 내부 프로젝트 네임스페이스 (예: using CompanyC.Api;)
  • 단일 파일에서만 사용되는 특수 네임스페이스

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/centralize-external-namespace-imports-mrwakg9s' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/centralize-external-namespace-imports-mrwakg9s/download' --output '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md.part' && mv '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md.part' '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md' && test -s '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/managing-global-usings' && cp -R '.skill-downloads/centralize-external-namespace-imports-mrwakg9s' '.claude/skills/managing-global-usings'

Cursor
test -f '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md' && test -s '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/managing-global-usings' && cp -R '.skill-downloads/centralize-external-namespace-imports-mrwakg9s' '.cursor/skills/managing-global-usings'

Codex
test -f '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md' && test -s '.skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/managing-global-usings' && cp -R '.skill-downloads/centralize-external-namespace-imports-mrwakg9s' '.agents/skills/managing-global-usings'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/centralize-external-namespace-imports-mrwakg9s'

openskills read 'centralize-external-namespace-imports-mrwakg9s'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/centralize-external-namespace-imports-mrwakg9s/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills