
結論:副業でも本業でも、作業時間の半分は“環境と段取り”で削れます。カギは ①保存で自動整形/静的解析、②ワンキーで一連実行(lint→test→report)、③再現性の担保(venv/pip-tools/pre-commit)、④VSCodeタスク+Makefileの二刀流。この記事では、settings.json
/tasks.json
/Makefile
/pre-commit
/requirements.in/out
までコピペで使える形で配布します(Windows/Mac両対応)。
この記事で身に付くこと
- 保存時に自動で整うVSCode環境(Black/Ruff/isort)
- ワンキーで回る一連実行(Format→Lint→Test→Report)
- 誰のPCでも同じ結果を出す再現性テンプレ(venv×pip-tools×pre-commit)
- Windows/Mac両対応のタスク/Makefileサンプル
>>Excel業務の自動化で月3万円:社内案件の作り方|“60分→10分”を商品化して社内受注する
>>データ可視化レポート納品の型:Tableau/Matplotlib|“図3点+結論1行+運用”で伝わる・続く・刺さる
>>【保存版】Python副業の始め方:月3〜10万円を目指す現実的ステップ
>>見積り・契約・著作権:トラブルを避ける基本知識|“スコープ×検収×知財”を先に決める
>>初案件はこの一通で決まる|返信率を上げる提案文テンプレ45選【コピペ可/検収基準・見積り付き】
時間が溶ける“3つのムダ”を断つ
現場で見てきたボトルネックは意外と単純です。まずはムダを言語化し、仕組みで潰します。
- ムダ1:手で整える……フォーマット/インポート整理/警告潰しを毎回手作業。
- ムダ2:手で回す……
lint→test→report
をコマンド3回打つ。 - ムダ3:手で説明……環境差異で「動かない」→説明工数が膨張。
対策は「保存で整う」「ワンキーで回る」「READMEで再現」の3点セット。以下のテンプレをそのまま入れるだけでOKです。
現場で定着した“型”(ふみとの実体験)
筆者(ふみと)は大手企業のデータ/マーケ現場で10年、案件は100件以上。導入初日に「保存で整う」と「Allタスク一括実行」を仕込むだけで、レビュー指摘や差し戻しが目に見えて減りました。メンバーが入れ替わっても品質が維持されるのは、ルールを人ではなく道具に任せるからです。
最短セットアップ(Windows/Mac共通)
① プロジェクト雛形を用意
project_root/
.vscode/
src/
tests/
data/
reports/
README.md
requirements.in
Makefile
pyproject.toml # black/ruff/isort/pytest等の設定置き場
.pre-commit-config.yaml
② 仮想環境+依存管理(pip-tools)
# Windows/Mac共通(PowerShell/Bash)
python -m venv .venv
. .venv/Scripts/activate # Windows PowerShell
# source .venv/bin/activate # macOS/Linux
python -m pip install --upgrade pip pip-tools
# 依存はrequirements.inに記述して固定化
cat > requirements.in << 'EOF'
black
ruff
isort
pytest
pandas
matplotlib
EOF
pip-compile -o requirements.txt requirements.in
pip-sync requirements.txt
③ VSCode 拡張&保存時整形
推奨拡張:Python、Pylance、Jupyter、Black Formatter(ms-python.black-formatter
)、Ruff(charliermarsh.ruff
)、GitLens、EditorConfig。
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": { "source.organizeImports": true },
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "basic",
"[python]": { "editor.defaultFormatter": "ms-python.black-formatter" },
"ruff.lint.run": "onSave",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true
}
Note:Windowsでうまく解決されない場合は.venv\Scripts\python.exe
を明示指定。
④ pre-commit(保存漏れを防ぐ最終防壁)
repos:
- repo: https://github.com/psf/black
rev: 24.4.2
hooks: [{id: black}]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.0
hooks: [{id: ruff}]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks: [{id: isort}]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- {id: end-of-file-fixer}
- {id: trailing-whitespace}
pip install pre-commit
pre-commit install # commit前に自動整形・静的解析
⑤ Makefile:一連実行の定番
.PHONY: setup sync lint test format report run clean
PY?=.venv/bin/python
PIP?=.venv/bin/pip
setup:
$(PIP) install --upgrade pip pip-tools
pip-compile -o requirements.txt requirements.in
pip-sync requirements.txt
sync:
pip-sync requirements.txt
lint:
$(PY) -m ruff check src tests
$(PY) -m isort --check --diff src tests
format:
$(PY) -m isort src tests
$(PY) -m black src tests
test:
$(PY) -m pytest -q
report:
$(PY) -m src.report
run:
$(PY) -m src.main
clean:
rm -rf .pytest\_cache .ruff\_cache **pycache**
Windowsでmake
が無い場合は、次のVSCodeタスクに置き換えればOK。
⑥ VSCode タスク(Make不要でも回る)
{
"version": "2.0.0",
"tasks": [
{
"label": "Setup",
"type": "shell",
"command": "python -m pip install --upgrade pip pip-tools && pip-compile -o requirements.txt requirements.in && pip-sync requirements.txt"
},
{"label": "Lint", "type": "shell", "command": ".venv/bin/python -m ruff check src tests || .venv/Scripts/python -m ruff check src tests"},
{"label": "Format", "type": "shell", "command": ".venv/bin/python -m isort src tests && .venv/bin/python -m black src tests || .venv/Scripts/python -m isort src tests && .venv/Scripts/python -m black src tests"},
{"label": "Test", "type": "shell", "command": ".venv/bin/python -m pytest -q || .venv/Scripts/python -m pytest -q"},
{"label": "All", "dependsOrder": "sequence", "dependsOn": ["Format", "Lint", "Test"]}
]
}
[
{"key": "ctrl+shift+l", "command": "workbench.action.tasks.runTask", "args": "All"},
{"key": "ctrl+shift+s", "command": "workbench.action.files.saveAll"}
]
⑦ デバッグ&ノートブック運用
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Run main",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/main.py",
"console": "integratedTerminal"
},
{
"name": "Python: Pytest",
"type": "python",
"request": "launch",
"module": "pytest",
"args": ["-q"],
"console": "integratedTerminal"
}
]
}
Jupyterのコツ:
・notebooks/
は実験、src/
は本番。Notebook→関数化→テストを習慣化。
・エクスポートはjupyter nbconvert --to html
でPDF代替。
・前処理はスクリプト化してNotebookから呼び出す。
“保存で整う”を保証する設定(pyproject.toml)
[tool.black]
line-length = 100
\[tool.isort]
profile = "black"
\[tool.pytest.ini\_options]
minversion = "7.0"
addopts = "-q"
\[tool.ruff]
line-length = 100
select = \["E","F","I","B"]
さらに半減する小ワザ集
- テンプレ化:雛形をGitHubのTemplate Repositoryに。
- スニペット:テスト/ログの雛形をUser Snippetsに登録。
- ターミナル分割:左で
pytest -f
、右でruff --fix
。 - Diff駆動:
pytest -q
の失敗から着手→最後にAll
実行。 - 共通ロガー:
src/utils/logging.py
に集約。 - Windows快適化:PowerShellプロファイルに短縮エイリアス。
README雛形(コピペ可)
# プロジェクト名
## 目的/KPI
- 例:定例レポートの自動生成(所要60→10分)
## 環境
- Python 3.11(.venv)/Windows 11 or macOS 14
## セットアップ
- `python -m pip install --upgrade pip pip-tools`
- `pip-compile -o requirements.txt requirements.in && pip-sync requirements.txt`
## 開発
- VSCodeで `Tasks: Run Task -> All`(Format→Lint→Test)
## 納品物
- `reports/weekly_report.pdf`、`README.md`、`CHANGELOG.md`
効果測定:時短の“見える化”
作って終わりにしないために、.timebook/
にBefore/Afterの所要時間をCSVで記録。短縮時間×人数×時給でROIを出し、月次で振り返ります。
→ [内部リンク:Excel業務の自動化で月3万円:社内案件の作り方]
トラブル対処の早見表
- VSCodeが.venvを掴まない→
Python: Select Interpreter
で.venv
選択。 - Ruff/Blackが走らない→拡張インストールと
settings.json
の[python]
確認。 - WindowsでMakeが無い→
tasks.json
のAllを使用。 - 依存が壊れた→
pip-sync
でクリーン、ダメなら.venv
再作成。
伴走の提案:レビューが早い環境で“現場仕様”に
設定の詰めと自動化の型は、質問初動と差し戻しが速い環境ほど早く整います。無料カウンセリング/体験で、あなたの開発環境にMake/Tasks/pre-commitを落とし込み、“保存で整う・ワンキーで回る”まで仕上げましょう。
TechAcademy データサイエンスコース(受講料:174,600円~ ※更に割引あり)

株式会社キカガク AI人材長期育成コース(受講料:237,600円~)

タイプ別の最短構築(用語は“読者像”で統一)
- 社会人(転職):Template Repo+Allタスク+pre-commitで「再現性が高い」実績に。→ [内部リンク:ポートフォリオ完全ガイド]
- 副業目的:定例レポート自動化にそのまま適用→運用月額へ展開。→ [内部リンク:データ可視化レポート納品の型]
- 主婦/夫(在宅):朝活/夜活でAllタスク前提の非同期SLAに合意。→ [内部リンク:リモートワーク前提の求人を探す方法と注意点]
今日やること(45分)
- このページのフォルダ雛形を作成→
.venv
+pip-compile/pip-sync
。 settings.json/tasks.json/Makefile/pre-commit
をコピペ→最小テストを通す。- VSCodeのタスク「All」にショートカットを割当→保存→Allの動線を体に刻む。
この記事から次に読むべきもの(内部リンク)
-
-
Excel業務の自動化で月3万円:社内案件の作り方|“60分→10分”を商品化して社内受注する
結論:社内のExcel定型作業(集計・整形・レポート化)をPythonで自動化し、月3万円の運用費(または評価/手当)を安定的に獲得するポイントは、①時間削減の定量化(ROI)、②納品の型(再現性と検 ...
-
-
データ可視化レポート納品の型:Tableau/Matplotlib|“図3点+結論1行+運用”で伝わる・続く・刺さる
結論:レポートは「データ→図」ではなく「意思決定→図」の順で設計します。最短で伝わり、運用で続く“型”は、(1) 結論1行、(2) 図3点(推移・分解・構成)、(3) 打ち手(閾値/費用対効果)、(4 ...
-
-
初案件はこの一通で決まる|返信率を上げる提案文テンプレ45選【コピペ可/検収基準・見積り付き】
初案件の提案、何を書けば“選ばれる”の? 長文は読まれないし、自己PRだけだと響かない…今すぐ使える“型”が欲しい! 提案は自己紹介ではなく、「相手のKPIを上げる約束」です。本記事では、現場で磨いた ...
-
-
単発を“毎月継続契約”に変える|週次10分レポートと改善バックログの型
単発納品を“毎月の継続契約(リテイナー)”に変えたい。結局、何から整えればいい? 毎週のレポート会って長くなりがち…。10分で意思決定まで持っていくコツは? この記事で身に付く力 単発納品をリテイナー ...
-
-
【保存版】Python副業の始め方:月3〜10万円を目指す現実的ステップ
Pythonの副業って本当に稼げるの?どうやって最初の1円を作ればいい? 結論、月3〜10万円は“再現性のある型”で十分現実的です。やるべき順番とテンプレをこの記事に全部まとめました。 この記事で身に ...
最近のコメント